Michael
Michael

Reputation: 8719

Updating Powerapps Global Variable property

I have a global variable in PowerApps which I set onstart.

Set(CurrentItem, First(Filter('Internal Review', ID=Value(Param("ID")))))

This sets the variable CurrentItem to

{ myProperty: 1, secondProperty: 2 }

I want to update "myProperty" in the global variable on a button click. I've got this:

Set(CurrentItem, { myProperty: 3 })

but its not working.

Upvotes: 2

Views: 7216

Answers (2)

Ansar
Ansar

Reputation: 396

Try this Set( CurrentItem, Patch( CurrentItem, {myProperty: 3 } ) )

Upvotes: 2

dinusc
dinusc

Reputation: 1

According to your formula, your global variable (CurrentItem) is bound to the "Internal Review" source. In your example it is currently { myProperty: 1, secondProperty: 2 } but it will change automatically if the respective values are changed in the source. You cannot change it because this would break the binding. I would suggest to copy it and then apply the desired changes to the copy. Example: Set(CurrentItemCopy, { myProperty: CurrentItem.myProperty, secondProperty: 3 })

Upvotes: 0

Related Questions