Wednesday - last edited Wednesday
I'm making a Custom Action API call to a target system (Maxio).
As part of this, I need to be able to pass two dynamically generated arrays of name:value pairs each time - one contains a list of restricted_products and the other a list of restricted_components.
When using the Guided Setup and supplying sample JSON for the Request Body like this...
... Workato correctly passes the data onto the Target system which takes the necessary action. So I know the JSON being passed in the intial setup is correct.
But then when I inspect the resulting Custom Action step in my Recipe, Workato has decided that the constituent product and component items which make up each of the arrays are fixed values. The Request Body Parameters portion of the action looks like this...
But the number and names of each product and component will vary each time.
How do I tell Workato that restricted_products are restricted_components are dynamic arrays, and pass in appropriate values?
Thanks in advance
Wednesday
Yeah, that's really your best bet. Take the string, reformat it into the object, pass the object as formula into restricted_components/products. Workato data pills rely on having pre-defined key name, so when your key names are dynamic you have to go with a more complex solution.
Thursday
I'm tantalisingly close... but still missing something ๐ฃ
My recipe is effectively just two blocks - one with the JS and another to execute the Custom Action.
The JS block takes a "list" input field which contains the comma separated list. The JS (thanks ChatGPT) turns the list into a suitably formatted object which is output in the "myJSON" field...
Here's the code for reference...
The myJSON output is then slotted into the custom action block like so...
I think the only problem is that, when run, the name and values (e.g. handle:component1) are not "quoted". Here's the result of running the job...
Whilst the target system (Maxio) does not choke on this, it also doesn't do what I want, so think it's just ignoring it.
Feels like I'm missing something very basic!