web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Add dynamically new pr...
Power Automate
Unanswered

Add dynamically new properties to existing array power automate

(0) ShareShare
ReportReport
Posted on by 4

I get response from an HTTP action and response is an Array like this :

{

"orderLines": [
{
"lineNumber": 1,
"productId": 100788762,
"brand": "test",
"productName": "productname",
"brandSku": "11-11-111",
"categories": [
{
"id": 31122,
"name": "Komponenter"
},
{
"id": 31134,
"name": "Audio"
}
],
"serialNumbers": []
},
{
"lineNumber": 2,
"productId": 100788232,
"brand": "test",
"productName": "productname",
"brandSku": "11-11-111",
"categories": [
{
"id": 31122,
"name": "Komponenter"
},
{
"id": 3134,
"name": "Audio"
}
],
"serialNumbers": []
}
]
}

 

And for each item i want add new properties (TrackandTrace,TrackandTracePath) like this :

{

"orderLines": [
{
"lineNumber": 1,
"productId": 100788762,
"brand": "test",
"productName": "productname",
"brandSku": "11-11-111",
"categories": [
{
"id": 31122,
"name": "Komponenter"
},
{
"id": 31134,
"name": "Audio"
}
],
"serialNumbers": [],

"TrackandTrace":"xxx",
"TrackandTracePath":"xxx"
},
{
"lineNumber": 2,
"productId": 100788232,
"brand": "test",
"productName": "productname",
"brandSku": "11-11-111",
"categories": [
{
"id": 31122,
"name": "Komponenter"
},
{
"id": 31134,
"name": "Audio"
}
],
"serialNumbers": [],

"TrackandTrace":"xxx",
"TrackandTracePath":"xxx"
}
]
}

 

Here is my flow :

Initialize New array:

Capture0.PNG

HTTP action:

Capture1.PNG

Assgin Value to varArrayLineExtraObj:

orderLines is an Array

Capture3.PNG

Loop:

Capture4.PNG

 

 

I know there is AddProperty , but how can i pass this properties dynamically TrackandTrace,TrackandTracePath to AddProperty and assgin them to each item in loop!

Categories:
I have the same question (0)
  • eliotcole Profile Picture
    4,363 Moderator on at

    Hi, @co21, I think that you have two options based on what you have said so far.

     

    addPropertiesDemo001-Setup.jpg

    ( originalObject here represents your html response, you may need to add levels to get to ?['orderlines'] )

    Add Extra Fields With Bespoke Information

    This will feel simpler or more logical to do which is why I'm mentioning it first. It also allows a semblance of automatic information to be included.

     

    So, if you know that those keys will never change, then you can simply create a a Select action after the HTML request on the 'orderLines' array. Just add all the fields that are already there, and add two additional ones with the data that you need.

     

    For each value you just add the relevant expression to pull that key from the old array. So for 'productId' that would be:

    item()?['productId']

    That looks at the item in the orderLines array and takes the value of the 'productId' field from it!

     

    This would be super-fast in flow terms, and would allow you to then either process that elsewhere, or dynamically add additional information within that Select action.

     

    For example, if the 'TrackandTrace' key is a combination of 'productId', two dashes, then the 'productName', then you'd use this in the value side:

     

    concat(item()?['productId'], '--', item()?['productName'])

     

    That would produce a "100788762--productname" value for your first item.

     

    In my example, I also made the TrackandTracePath do this:

    concat('/(', item()?['productId'], ')', item()?['productName'], '/TrackandTrace')

    Which for the first item would produce a "/(100788762)productname/TrackandTrace" value in that field.

     

    Simpler Method - Add Blank Fields

    This would also be able to be done with unknown key names, too, and just inserting null 'TrackandTrace' and 'TrackandTracePath' keys, using something like this:

     

    addProperty(addProperty(item(), 'TrackandTrace', null), 'TrackandTracePath', null)

     

    To add that, you switch the You would add that using the 'JSON' view ("text mode") of the Select key/value pairs. The button is just to the right and looks like this:

    text view.jpg

     

    You could include *some* customisation there, but it would start to get complex.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 462 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 456 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard