Question

Working with arrays coming as an output from triggers

  • 30 September 2023
  • 1 reply
  • 132 views

Userlevel 1

There’s an external API that returns an array among the members of its output object:

{

    "id": "a8a9e039-fadc-4799-b891-187a53fb7f5e",
    "userId": "ADMIN",
    “headings": [
{
"rank": 0,
"name": "Meubles 1",
"modelCode": "08",
},
{
"rank": 1,
"name": "Services",
"modelCode": "",
}
]
}

The array is of variable length. I’d like to allow users to work with items of this array.

 

My integration is defined in Platform CLI. Following the documentation, I used in the fields [] to indicate the array:

{
version: '1.1.1',
authentication: <omitted>,
triggers: {
file_new: {
operation: {
type: 'hook',
outputFields: [
{ key: 'instanceGuid', label: 'App instance that triggered the event' },
{ key: 'userId', label: 'User Id', type: 'string' },

{ key: 'headings[]rank', type: 'integer', label: 'Heading Rank' },
{ key: 'headings[]name', type: 'string', label: 'Heading Name' },
{ key: 'headings[]modelCode', type: 'string', label: 'Heading Model Code' },
<omitted>
],
<omitted>
}
}
}



But the trick appear not to work. In a zap I can’t do anything useful with the headings field, thow the data returned by the trigger surely contains several records.

 

So how could we allow users working with an array contained in the output?

 


This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

1 reply

I am also facing the same issue.

When I used the “Generate Output Field Definitions” button in the trigger’s “Define your Output” section, it generated a bunch of line items for an array field, giving an impression that it would split the array into multiple line items which can be consumed by the user with “records[]0”.

This doesn’t seem to be working that way though. When the “records” array has data like [“A”, “B”, “C”]. The “records[]0” value seems to be empty. It works when the user tries with a loop on the “records” field and access line items form the loop output.