Reputation: 307
I need an Azure Workflow solution to the following, I’ve looked on line but can’t find a workflows specific answer…
I have a ‘Pars JSON’ type in my workflow that holds a ‘phones’ type as an array so when I try to use this with my ‘create record’ type it automatically puts the ‘create record’ object in a FOR loop, which breaks the workflow.
Phones is defined as:
"phones": [
{
"phonetype": {
"id": "D04830",
"formattedvalue": "Mobile",
"value": "Mobile"
},
"entry": 418320,
"phonenumber": "+123 4567 8910",
"primary": true
}
But there will always only be one ‘phonenumber’ value and I need to get this out of the array so it can be used as a single value in the create record type.
e.g.
In the example firstname, lastname, and email are all fine as they are single values coming from the Pars type holding the JSON. I need to make an object that can be put into the phone field as I can’t do this directly because the phone type in the JSON is an array.
I can see the phone number needed by doing this:
But I can’t see the ‘Compose phone Number’ outside of the FOR LOOP. It’s that value I need to put in the ‘Create a new D365HR Worker record’ item.
Why can't I do something like this:
Because it's only ever going to return one thing anyway! I’m still new to workflows so any help would be appreciated.
Upvotes: 0
Views: 34
Reputation: 11197
Use a Compose
operation and inject an expression which uses the first()
function, e.g. ...
first(variables['My Variable']['phones'])?['phonenumber']
... something like that. You’ll just need to change the My Variable part out for the object that’s holding the phone array.
That will help you avoid the loop.
Upvotes: 0