The first item doesn't have a ABC property, so the error is correct. In this example the expression would be referencing the second item
body('Select')[1]['ABC']
If you don't know in which item the ABC property is, you can use an apply to each for this as well and reference the ABC property with the item function:
item()?['ABC']
You can also use a Filter Array as well to find the matching item.
Btw, do you mind creating a separate thread for this. It is easier to help you out over there.
I tried that. but first() or index is referencing to the first array element. So, i am not able to get the values using the keys.
InvalidTemplate
. Unable to process template language expressions in action 'Compose_2' inputs at line '0' and column '0': 'The template language expression 'first(body('Select'))['ABC']' cannot be evaluated because property 'ABC' doesn't exist, available properties are 'XYZ'. Please see
https://aka.ms/logicexpressions
for usage details.'.
Here XYZ is the first key of the first element.
[
{
"XYZ"
:
"492"
},
{
"ABC"
:
"477"
}
]
i want to know the value of ABC. the array is not fixed. the key values are dynamic. so i need to fetch the data using the key.
The Select returns an array. So, you could use an apply to each loop to loop through it and use the columns and values.
Alternatively, you can use an expression to retrieve a specific item of the array.
The first item would be:
first(body('Select'))
The company name of the first item would be
first(body('Select'))['Company Name']
You can also use an index for referencing items. The index always start counting with 0 (first item). So that would be 1 (second item), 2 (third item), 3 (fourth item), etc.