<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Using object datatypes in Community Chat</title>
    <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5964#M139</link>
    <description>&lt;P&gt;If I understand correctly - you have to transform emails in a specific data structure and in multiple recipes.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Preferred way would be :&amp;nbsp;&lt;BR /&gt;Utilize callable sync function where&amp;nbsp; the transformation of emails to json occurs as already described in my previous reply and call that function with input: ; seperated email and outputs desired json. This way you can call it from multiple recipes.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jan 2024 15:39:11 GMT</pubDate>
    <dc:creator>kkamal</dc:creator>
    <dc:date>2024-01-12T15:39:11Z</dc:date>
    <item>
      <title>Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5923#M136</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am trying to perform a HTTP request with a JSON payload containing a subset of data but I cannot work out how to get this to work. In my scenario and example data structure to build would be as shown below with the "email" data being what I am trying to build.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "first_name": "John",
    "last_name": "Hancock",
    "email": [
        {
            "email_address": "test@test.co.uk",
            "primary_address": true,
        },
        {
            "email_address": "test2@test.co.uk",
            "primary_address": false,
        },
    ]
}&lt;/LI-CODE&gt;&lt;P data-unlink="true"&gt;&amp;nbsp;I have a recipe that is given an email address string so in this example it would be "test@test.co.uk; test2@test.com"&amp;nbsp;which splits by the semicolon. It then needs to build the array data to return to the primary recipe that calls this and that is where I have been having issues. I tried using a list variable which I added to in a loop but it doesn't allow me to select the data, it looks like it assumes I will be wanting to select each row of data.&lt;/P&gt;&lt;P data-unlink="true"&gt;I realise I probably haven't explained that brilliantly but if anybody can help that would be appreciated.&lt;/P&gt;&lt;P data-unlink="true"&gt;Many thanks,&lt;/P&gt;&lt;P data-unlink="true"&gt;Liam&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 14:23:57 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5923#M136</guid>
      <dc:creator>enable_services</dc:creator>
      <dc:date>2024-01-09T14:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5924#M137</link>
      <description>&lt;P&gt;IMHO, I have found the solution for such use cases is using javascript connector which takes in the variables to process.&amp;nbsp;You could wrap the logic of getting the JSON in&amp;nbsp; javascript connector function. That JSON could directly be added as value in the HTML request body formula.&amp;nbsp;&lt;BR /&gt;considering first_name, last_name, emails (; delimited),&amp;nbsp;&lt;BR /&gt;- Consider below as an example to retrieve json from javascript connector.&amp;nbsp;&lt;/P&gt;&lt;P&gt;exports.main =&amp;nbsp; (input) =&amp;gt; {&lt;/P&gt;&lt;P&gt;const { first_name, last_name, emails} = input&lt;/P&gt;&lt;P&gt;return { first_name, last_name, emails: emails.split(";").map((email, i) =&amp;gt; ({ email_address: email ? email.trim(): '', primary_address: i ==0 ? true : false}))}&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jan 2024 18:53:15 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5924#M137</guid>
      <dc:creator>kkamal</dc:creator>
      <dc:date>2024-01-09T18:53:15Z</dc:date>
    </item>
    <item>
      <title>Re: Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5934#M138</link>
      <description>&lt;P&gt;Presumably that would mean I have to update all of my current recipes as I use the SugarCRM app connector and use a custom event action to define my own URL. So all of the logic across the recipes for both my helper functions and other datasets work using the usual mapping setup of selecting datapills. Or can I use the javascript connector for my helper function recipe to return JSON? I had historically tried returning JSON using the .to_json array modifier on the list I built and returning that which seemed to build correctly however in the main recipe where I define the request body fields the only suitable type was text but that resulted in the 'email' data being quoted if I recall meaning it wasn't valid JSON anymore.&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
    "email": "[{"email_address":"test@test.com","primary_address":true}]"
}&lt;/LI-CODE&gt;&lt;P&gt;I don't have that example to hand to confirm it was like that but it wasn't working (I can get the exact example if needed).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 09:26:04 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5934#M138</guid>
      <dc:creator>enable_services</dc:creator>
      <dc:date>2024-01-10T09:26:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5964#M139</link>
      <description>&lt;P&gt;If I understand correctly - you have to transform emails in a specific data structure and in multiple recipes.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Preferred way would be :&amp;nbsp;&lt;BR /&gt;Utilize callable sync function where&amp;nbsp; the transformation of emails to json occurs as already described in my previous reply and call that function with input: ; seperated email and outputs desired json. This way you can call it from multiple recipes.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 15:39:11 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5964#M139</guid>
      <dc:creator>kkamal</dc:creator>
      <dc:date>2024-01-12T15:39:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5973#M140</link>
      <description>&lt;P&gt;Yes that is correct so I already had a function recipe setup to do the email transformation that builds an empty list variable and then adds items to it, but that is where&amp;nbsp; my problems started. In trial and error attempts to get it to work I made the function recipe return the below fields.&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;"addresses" string type field which is the compiled list converted to JSON using the .to_json method&lt;/LI&gt;&lt;LI&gt;"emailObj" object type field&lt;/LI&gt;&lt;LI&gt;"addressesList" array type field&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;However in the function return step it will not allow me to select my list variable for the object or array type fields. I want to return an array type field of the compiled list of email addresses data so I get it to return an array of data like in my original question for the list of email addresses and then select that returned data in the primary recipe that called the function recipe.&lt;/P&gt;&lt;P&gt;However it doesn't look immediately to me like this is possible which is why I have got stuck as I tried using the "addresses" to_json converted data as a naff workaround into a string field on my primary recipe but then it sends the sub email JSON as a quoted string meaning it isn't valid JSON anymore.&lt;/P&gt;&lt;P&gt;I can do a lookup up of a remote system that returns a primary record will related child records that I can then loop over using the repeat action, this is just the reverse of this that I am trying to do where I am trying to push a data a parent with children to the remote system. If I can't get it to work I will have to just send in the data in an unformatted source string value and then add code into the remote system to handle this special case but I will be disappointed if I have to resort to this.&lt;/P&gt;</description>
      <pubDate>Tue, 16 Jan 2024 12:30:02 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/5973#M140</guid>
      <dc:creator>enable_services</dc:creator>
      <dc:date>2024-01-16T12:30:02Z</dc:date>
    </item>
    <item>
      <title>Re: Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6009#M144</link>
      <description>&lt;P&gt;I managed to work out how to get the function recipe to return an actual correct array of object data, you have to manually edit the JSON schema to set the "properties" as sub fields which it doesn't support in the UI seemingly. Annoyingly it still won't let me use the returned response in my main recipe for the connector mapping as an array type field, though I know it has returned correctly as I can do a repeat loop on it.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 17:00:38 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6009#M144</guid>
      <dc:creator>enable_services</dc:creator>
      <dc:date>2024-01-22T17:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6013#M145</link>
      <description>&lt;P&gt;Glad that you were able to work out.&amp;nbsp;&lt;/P&gt;&lt;P&gt;|&amp;nbsp;&lt;SPAN&gt;Annoyingly it still won't let me use the returned response&lt;BR /&gt;&lt;BR /&gt;For correct mappings the schema need to be set. Have you set the output response schema for the function being called ?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 22 Jan 2024 17:35:38 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6013#M145</guid>
      <dc:creator>kkamal</dc:creator>
      <dc:date>2024-01-22T17:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6021#M146</link>
      <description>&lt;P&gt;Yes I set the function return step to return an array type field with sub field properties of strings and boolean fields. When I run the primary recipe that calls it I can see I get a response and that response is an array with a row of object data as you would expect. If I try to use a repeat action it allows me to select that returned response to loop over however it won't let me select it in the connector HTTP request mapping where I have defined a request body field of type array. So either I am doing something wrong here or the SugarCRM Connector that I have been using doesn't support it for some reason.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 08:53:14 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6021#M146</guid>
      <dc:creator>enable_services</dc:creator>
      <dc:date>2024-01-23T08:53:14Z</dc:date>
    </item>
    <item>
      <title>Re: Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6022#M147</link>
      <description>&lt;P&gt;Oh, i would recomment in the http connector -&amp;gt; body field to be type normal text which would allow you to actually use formula mode and in that formula mode you can directly put the array value&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Jan 2024 09:44:19 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6022#M147</guid>
      <dc:creator>kkamal</dc:creator>
      <dc:date>2024-01-23T09:44:19Z</dc:date>
    </item>
    <item>
      <title>Re: Using object datatypes</title>
      <link>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6031#M148</link>
      <description>&lt;P&gt;Right OK that works though it is rather counter-intuitive to be able to define an return an array but to use it in an HTTP connector to have to put it into a string type field specifically in the formula section. For anybody that comes across this forum please be aware this will quote any boolean properties of the array as strings for example instead of&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;[{"email_address": "myaddress@gmail.com", "primary_address": true}]&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;you would get&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;[{"email_address": "myaddress@gmail.com", "primary_address": "true"}]&lt;/LI-CODE&gt;&lt;P&gt;So if you have any code that checks for those boolean types you will need to cater for this, in my instance I changed them to integer properties and sent across 0 and 1 as an equivalent value for when it goes into the SQL database the application is connected to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jan 2024 12:51:57 GMT</pubDate>
      <guid>https://systematic.workato.com/t5/community-chat/using-object-datatypes/m-p/6031#M148</guid>
      <dc:creator>enable_services</dc:creator>
      <dc:date>2024-01-24T12:51:57Z</dc:date>
    </item>
  </channel>
</rss>

