cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
oliverbusk
Level: Powered On

Get access to multiple elements of array outside of loop

Hi

I have some JSON data, that looks like this:

 

{
 "hs_code": [
    {
      "type": "custom",
      "number": "30049000"
    },
    {
      "type": "custom",
      "number": "90258040"
    }
  ],
  "statistic_value": [
    {
      "key_0": "226800  DKK"
    },
    {
      "key_0": "0  DKK"
    }
  ]
}

 I want to access this data and send it all in an e-mail to myself, formatted like this:

 

Hi Oliver

Please see below data:

HS Code:
30049000
90258040
Values:
226800 DKK
0 DKK

However I cannot figure out how to get all values from the JSON object. I have tried creating a For Each loop, but here I can only loop through either "hs_code" OR "statistical_value". And I am not even able to access the variable outside of the loop.

Can anyone assist me in creating above flow? Sounds really simple in my head, but I find it very hard to do in Flow.

 

 

2 REPLIES 2
Community Support Team
Community Support Team

Re: Get access to multiple elements of array outside of loop

Hi @oliverbusk,

 

I have made the following test, please take it for a reference.

The flow is triggered by a button.

Initialize variable, Name set as type, Type set as Object, Value set as the JSON schema you provided.

Add a Compose action, input the following code:

variables('type')?['hs_code'][0]['number']

Add a Compose 2 action, input the following code:

variables('type')?['hs_code'][1]['number']

Then in the send an email action, enable Yes for the Is HTML field, and select the dynamic contents from Compose and Compose2 in the email body.

Please check it for a reference and try with the remaining part on your side.

1.PNG

There is blog for your reference:

https://sergeluca.wordpress.com/2017/11/23/using-json-in-microsoft-flow-part-1/ 

 

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Administrator
Administrator

Re: Get access to multiple elements of array outside of loop

Hello, @oliverbusk!

Thank you for posting on the Flow Community Forum! Have you had an opportunity to apply @v-yamao-msft‘s recommendation to adapt your Flow? If yes, and you find that solution to be satisfactory, please go ahead and click “Accept as Solution” so that this thread will be marked for other users to easily identify!

Thank you for being an active member of the Flow Community!

-Gabriel
Flow Community Manager

-Gabriel
Microsoft Power Automate Community Manager
Are YOU a member of your local Power Automate User Group?
Fill out This Form to claim your Community User Group Member Badge!

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

firstImage

Incoming: New and improved badges!

We've given our badges an overhaul and also added some brand new ones!

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Kudoed Authors (Last 30 Days)
Users online (4,660)