cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Build and Replace Array

Hi Powerusers,

 

I'm making two HTTP Requests to get JSON from two different services, I then parse out the JSON into thier own variables in dynamic content.

 

One request contains an array of valid ID's, with the following format: 

 

{"objectIdFieldName":"objectid","objectIds":[1,2,4,5,6]}

The second request contains an array, named 'order', which has id's that are old and invalid. It has the following format:

 

{"_ssl":null,"source":"91d75e9b375e4e9b9b3a4004544bfadf","values":{"order":[{"id":1,"visible":true},{"id":2,"visible":true},{"id":3,"visible":true},{"id":4,"visible":true},{"id":5,"visible":true},{"id":6,"visible":true},{"id":7,"visible":true},{"id":8,"visible":true}],"title":"Missing Children Cases Map Tour","colors":"#444;#B4B4B4;#E5E5E5","layout":"side-panel","social":{"bitly":false,"twitter":false,"facebook":false},"webmap":"989ddcd5ac6a4155b18f96875d05108d","logoURL":null,"template":"Map Tour","zoomLevel":"12","logoTarget":null,"sourceLayer":"service_df9e032e61cf4e6cbaa4da750930c723_478","headerLinkURL":"https://storymaps.arcgis.com","fieldsOverride":{"fieldID":"objectid","fieldURL":"pic_url","fieldName":"name","fieldThumb":"thumb_url","fieldIconColor":"objectid","fieldDescription":"description"},"headerLinkText":"A Story Map","locationButton":true,"placardPosition":null,"templateVersion":"2.12.1","templateCreation":"2.12.1"},"folderId":"86a73fd80e38466c92d52f3fd81c09c2"}

 

Each "id" property in the second requests order array may be invalid, and must be replaced with all results from the first request objectids array. 

 

Essentially what I need to do is build a new array with only the id's found in the first requests objectids array and replace the "order" array in the second request with that newly built one. This new array has to contain both properties of id and visible (visible will always be true). 

 

I've approached this in integromat by looping through the first objectIDs array, adding the id and visible property each time to that new array, I then post that new array to the service, overwriting the invalid list of ids.

 

Is this possible in Flow? I'm caught up a bit on how to loop through each ID in the first request and build a new array.

 

 

Thanks in advance for your help,

 

 

Tom

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper I
Helper I

Re: Build and Replace Array

I was able to solve this last week while my post was marked as spam. It was actually easier than I expected, at the time of this post I did not know we were able to create new arrays.

 

I first initialized a new array:

 

Array.PNG

 

I then looped through the ObjectID Array, and with each iteration of the loop I appended that value as the Current Item to the array.

 

LoopArray.PNG

 

Lastly, I passed that completed, new array into an HTTP POST request, overwriting the invalid array with the valid array.

 

Passing.PNG

 

 

 

This workflow replaced the Inteogromat workflow I had been using, very happy with it.

 

 

Tom

 

View solution in original post

2 REPLIES 2
Highlighted
Community Support
Community Support

Re: Build and Replace Array

Hi @tthompsonesri,

 

You could take a try to achieve your needs with microsoft flow even though maybe it is difficult.

 

Best regards,

Alice

Highlighted
Helper I
Helper I

Re: Build and Replace Array

I was able to solve this last week while my post was marked as spam. It was actually easier than I expected, at the time of this post I did not know we were able to create new arrays.

 

I first initialized a new array:

 

Array.PNG

 

I then looped through the ObjectID Array, and with each iteration of the loop I appended that value as the Current Item to the array.

 

LoopArray.PNG

 

Lastly, I passed that completed, new array into an HTTP POST request, overwriting the invalid array with the valid array.

 

Passing.PNG

 

 

 

This workflow replaced the Inteogromat workflow I had been using, very happy with it.

 

 

Tom

 

View solution in original post

Helpful resources

Announcements
FirstImage

Microsoft Ignite 2020

Check out the announcement of Power Platform content at Microsoft Ignite!

thirdImage

Experience what's new for Power Automate

Join us for an in-depth look at the new Power Automate features and capabilities at the free Microsoft Business Applications Launch Event.

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (5,072)