# Pass Record as function parameter

**URL:** <https://forum.cloverdx.com/t/pass-record-as-function-parameter/2041>\
**Category:** CloverDX Platform\
**Created:** [May 23, 2019, 12:00am UTC](https://forum.cloverdx.com/t/pass-record-as-function-parameter/2041 "2019-05-23T00:00:00Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![iseewebpeople](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/iseewebpeople/32/126_2.png) [@iseewebpeople](https://forum.cloverdx.com/u/iseewebpeople)\
**Post date:** [May 23, 2019, 12:00am UTC](https://forum.cloverdx.com/t/pass-record-as-function-parameter/2041/1 "2019-05-23T00:00:00Z")

</div>

In my scenario I have the need to set default identical yet dynamic values on multiple output tables.

I have a global ctl file which I import into transformations.  
Within this I have set up a number of maps for the fields to be written depending on type and I can then check the output metadata for those fields and write them where found with the relevant setValue function.

Now, the issue comes where I want to write these on multiple output ports as I cannot reference the ports if they don’t exist on the particular reformat I’m using.

For instance:  
ReformatA has 2 output ports  
ReformatB has 1 output port

If my method sets $out.0 and $out.1 then Clover will throw an error initializing as ReformatB does not have 2 output ports.

So I want to pass the record itself into the method as a parameter rather than specifically write to the output port in the code, that way I can do it dynamically… problem being CTL doesn’t seem to support the datatype of “record” as an input parameter.

The other option is being able to dynamically check for the connected ports within the function and handle it accordingly.

Does anyone have an idea as to how I can achieve this or am I just banging my head against a brick wall here?

For now I have created a ctl file for each input port with the exact same function in it (allbeit referencing different ports) and I then just include the ones I need but this is far from ideal as I need to import multiple ctl files each time and then use a different method name for each output port.

Any and all help much appreciated.

Cheers

Simon

---

<div class="post-metadata">

**Author:** ![andras.csore](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@andras.csore](https://forum.cloverdx.com/u/andras.csore)\
**Post date:** [May 24, 2019, 10:01am UTC](https://forum.cloverdx.com/t/pass-record-as-function-parameter/2041/2 "2019-05-24T10:01:34Z")

</div>

Hi Simon,

Can you add a little more details (or sample graph)… I read thru 4 times, but in don’t get it … ☹  
Anyhow, may GetrecordProperties helps?  
[https://doc.cloverdx.com/latest/designer/field-access-functions-ctl2.html#ctl2-getRecordProperties](https://doc.cloverdx.com/latest/designer/field-access-functions-ctl2.html#ctl2-getRecordProperties)

Andrase,  
Forum member (not Clover support)

---

<div class="post-metadata">

**Author:** ![Lukas\_Cholasta](https://yyz1.discourse-cdn.com/flex007/user_avatar/forum.cloverdx.com/lukas_cholasta/32/166_2.png) [@Lukas\_Cholasta](https://forum.cloverdx.com/u/Lukas_Cholasta)\
**Post date:** [May 29, 2019, 1:05pm UTC](https://forum.cloverdx.com/t/pass-record-as-function-parameter/2041/3 "2019-05-29T13:05:23Z")

</div>

Hi,

Unfortunately, there is no CTL function to dynamically detect number of component ports.

However, it is possible to work around this by using a [SimpleCopy component](https://doc.cloverdx.com/latest/designer/simplecopy.html#simplecopy). If you put this component behind your Reformat component, the code can be more generic and pass the output to only one record every time and the SimpleCopy will distribute it to as many edges as needed. In other words you’ll detach the code from the actual graph design.

You can also send a record as a CTL function parameter. However, there is no keyword like **record** ,therefore, you need to use metadata name to [declare a record datatype](https://doc.cloverdx.com/latest/designer/data-types-in-ctl2.html#ctl2-record) as every record in CloverDX have to be described by metadata.

Both of the above is shown in the attached example project. Please try to import it into your Designer and review. Let me know if it helped you with your use case. If this is not what you’re looking for, please get back to me with more details.

Best regards.

- [PassRecordAsParameterInCTL.zip](https://cdn.cloverdx.com/forum/18108%5Fde2cd0a149c2cc3ff16232d20caab5b4/PassRecordAsParameterInCTL.zip)
