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

How to set property value on a object-type variable?

Hi all

 

I'm stuck with the following problem:

I would like to change a property value of an object-type variable. 

I read this amazing blog: http://johnliu.net/blog/2017/7/json-cheatsheet-for-microsoft-flow

 

These are my initialises:

 

 1.png
Here I would like to change the value of the property "test". 
As you can see, I would like to use the value of variable "dc", as the name of the property. 

This works, but using the value of the variable not..

"@json('{\"test\": 2}')"

2.png3.png

 

Could someone help me out? 

 

Many thanks. 

Bram

2 REPLIES 2
Community Support
Community Support

Hi @bramc,

 

Could you provide more details about your needs?

Obviously, using variables here instead of property names is not in line with the specification.

There is no similar way to set the property value in the article.

It seems that you can only reference property names to set property values. And the property name compulsory is a constant, you cannot use variables.

 

Best Regards,

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

Hi Barry

 

Thank you for your answer. 

 

This was just a little test, because I have a "big" program where I would've liked to implement this. 

The program does the following:

 

I have a Sharepoint List with a lot of data (points from the evalutions of the students at school).

Each evaluation belongs to a theme. There are like 20 different themes. 
In the SP list, there are columns like studentnumber, theme, score, maximum_score, ...

 

I iterate through each student, and within this iteration I iterate through each SP list item from this student. 

At this moment, I have many variables (for each theme a variable total_score, total_max_score) and many conditions and switch cases.. All the initialises, and the resets after each iteration..

The flow is getting too big, at this point each action I want to make takes like 5 seconds to appear.

In the end, I need to calculate all the percentages from each theme and make reports. 

 

That's why I hoped to get this working. 
If this would be possible, I can get a SP list item, check the 'theme' and then iterate through all the SP list items with the same theme (from the specific student). And then write the percentage to the variable-object. 

Then I would only need 2 variables instead of 20, and much less conditions and cases.. 

 

My object-variable would be initialised like this and I would overwrite the property value of each theme (if the theme was evaluated): 

{

"theme_1" : 0,

"theme_2" : 0,

...

"theme_20": 0

}

 

I hope you can make me a bit wiser, because it's not easy anymore. 

 

Many thanks
Bram

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Top Solution Authors
Top Kudoed Authors
Users online (13,031)