Reputation: 1
I use in-line code action to get the user's info and return an array, now i want to get the email address and the name to send an email.
I tried the expression: Outputs('action name')[1], but it shows that the template is invalid.
Thank You!
How can i get the values(name and email address) in this array?
Upvotes: 0
Views: 747
Reputation: 11411
I do agree with @BrunoLucasAzure, And assuming your output from Inline code will be something like:
[{
"Email_Address":"[email protected]",
"name":"Rithwik"
}]
Now firstly you need to set the output to a variable or initialize it to a variable then you can use below steps:
variables('emo')[0]['name']
Output:
If you want email address then use:
variables('emo')[0]['Email_Address']
Output:
Upvotes: 0
Reputation: 199
to get a specific field of one array element you can use this:
variables('MyArray')?1?['Email_Address']
Where MyArray is the name of the Array Variable:
1 is the array element position and [Email_Address] the element field
Considering the Array:
[
{
"Email_Address": "[email protected]",
"Email_Address2": "[email protected]",
"Email_Address3": "[email protected]"
},
{
"Email_Address": "[email protected]",
"Email_Address2": "[email protected]",
"Email_Address3": "[email protected]"
}
]
variables('MyArray')?1?['Email_Address'] will result in:
But are you sure the value you need will always be in the same place? is the array always the same amount of items?
maybe you may find better alternatives with an Array filter. https://learn.microsoft.com/en-us/azure/logic-apps/logic-apps-perform-data-operations?tabs=consumption#filter-array-action?WT.mc_id=AZ-MVP-5005174
Upvotes: 0