How to add property on an object power apps

1.7k views Asked by At

I'm trying to build an app with power apps, I created a form where I collect data and then create a new object to store it in a collection, the problem is that i need to be able to modify the properties of that object and I can't.

I'm using Set() to create the object with all the properties already filled, like this :

Set(newObj, {property1: value, property2: value, property3: value; ...})

But whenever I try to Patch it to modify or add properties it does not work, nothing is added or modified

I'm doing Patch like this :

Patch(newObj, {newProperty: value, propertyToModify: value})

Do you know what i'm doing wrong ?

2

There are 2 answers

1
AnkUser On BEST ANSWER

You cannot add any new property to your object with Patch. With patch you can only add rows to this object and not change the definition of you object by adding new property.

with set you have defined your object with property1,property2 and property3.

You will have to define your object completely in set.

so it will be like

Set(newObj{property1: value, property2: value, property3: value; newProperty: value, propertyToModify: value})
1
David Jorgensen On

Note that you don't need to redefine your object like that. The key thing to remember is that Patch doesn't update the record, it returns the updated record. You can then use Set to set your object, like this: Set(newObj,Patch(newObj,{newproperty:4}))