0

New to Power Automate and I'm struggling with what seems to be a very small problem and likely be a doddle for someone to resolve:

I have an array that looks like this:

{
"index": 0,
"text": "Customer reference"
  },
  {
    "index": 1,
    "text": "Customer id"
  },
  {
    "index": 2,
    "text": "21009515004"
  },
  {
    "index": 3,
    "text": "Bill number"
  },
  {
    "index": 4,
    "text": "11023587"
  }
]

And I need to Select or assign to a variable the 'text' value where 'index' value is specified.

So I need the value "11023587" by selecting "index" = 4

2 Answers 2

1

You can also use the switch method to achieve this,here is an example:

enter image description here And the result:

enter image description here

0

I created a variable to store an array.

Initialize variable action

I can then use a Filter array action to find the object in the array that has index equal to 4. The expression shown in the screen capture is item()['index'].

Filter action

To get the output from the Filter array action you use the expression body('Filter_array'). This will be an array. To get the object from the array you use the expression first(body('Filter_array')). Finally, to get the text property from the object you use the expression first(body('Filter_array'))['text']. You can get this value in the flow using a Compose action.

Compose action

I hope this helps.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.