cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frequent Visitor

How to change properties of object in bulk?

I've set an entity inside a loop with many properties.

entity = {id:1, name:link, date:20201111, note:'',...}

 

I must use the 'setProperty' method to assign a value to each property.
My process now looks like this, which is uncomfortable to read

 

 

for (list) {
// reset entity
set(var(entity), json(id:'',name:'',...))

// set entity
setProperty(var(entity),key,val)
setProperty(var(entity),key,val)
setProperty(var(entity),key,val)
setProperty(var(entity),key,val)
setProperty(var(entity),key,val)
setProperty(var(entity),key,val)


Add a row into a table{
    file:...,
    table:...,
    row:var(entity)
}

.... 
}

 


Is there a way to assign values in bulk?
or you can merge these assignment statements into a single statement?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Super User III
Super User III

Yes, you can just write a compose and define the whole thing in one step. Here is one like it in one of my flows:

composeObject.PNG

Does that make sense?

View solution in original post

2 REPLIES 2
Super User III
Super User III

Yes, you can just write a compose and define the whole thing in one step. Here is one like it in one of my flows:

composeObject.PNG

Does that make sense?

View solution in original post

Frequent Visitor

Yes, this is what I was hoping for.

Thank you!


There may be a problem with my json splicing, I used to use the json function to convert the string to set the value.
It's horrible to write.😅

json('{
"name":"link",
"age":' + items('getAge') + ',' +
'"item":' + .....,
}')

// or use json(concat( ... ))

 

Helpful resources

Announcements
PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

MPA Community Blog

Power Automate Community Blog

Check out the community blog page where you can find valuable learning material from community and product team members!

Top Solution Authors
Users online (4,075)