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.
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.
Share Improve this question edited Jan 31 at 16:56 Garry_G asked Jan 31 at 13:26 Garry_GGarry_G 3096 silver badges13 bronze badges 3- Hi Garry, does the phones array only contain a single value ? or are multiple values and you need to pick the one where primary is true? – Cristian Teodorov Commented Jan 31 at 13:56
- It will only ever contain one value in this instance. – Garry_G Commented Jan 31 at 15:38
- The 'Primary' value will always be true. – Garry_G Commented Jan 31 at 16:27
1 Answer
Reset to default 0Use 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.