cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User
Super User

Updating a set variable before writing it to a new sharepoint item.

I need a way to update a set() variable, without totally rewriting it.  I want to aviod the extensive syntax.  Am I missing something simple?  Or, do I have to do the long form.  This is what I would like to do:

 

Set(SelectedItem, Lookup(SharepointDatabase, Partnumber=12345));
SomeCommand(SelectedItem, {Partnumber: 54321});
Collect(SharepointDatabase,SelectedItem)

Patch(), Collect(), Update() do not work for this.  Am I missing something?  Or, a typical syntax oddity that I need to know?

 

Thank you.

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
mdevaney
Level 8

Re: Updating a set variable before writing it to a new sharepoint item.

@martinav 

Hello there Martin.  Its nice to be hosting one of the Flownauts here in the PowerApps community!  I took a read of the documentation for the SET function and it appears what you are asking is possible.  However, the solution relies on an uncommon  usage of the PATCH function that I was not familar with until moments ago.  Let's do a mini-tutorial together Cat Very Happy 

 

Create a button and put this code in the OnSelect property.

Set(Person,{Name: "Milton", Address: "1 Main St"});

 

Next, create a new label called Label1 and put this code in the Text property.

Person.Address

 

The label will display this text string

1 Main St

 

Now create a 2nd button and put this code in the OnSelect property.

Set(Person, Patch(Person,{Address: "2 Main St"}));

 

Your label will now displaythis text string

2 Main St

 

I think this will do the trick.  Let me know if my proposed solution works for you!

 

FYI, here's the link to the MS documentation where I found the example. https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-set

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

2 REPLIES 2
Highlighted
mdevaney
Level 8

Re: Updating a set variable before writing it to a new sharepoint item.

@martinav 

Hello there Martin.  Its nice to be hosting one of the Flownauts here in the PowerApps community!  I took a read of the documentation for the SET function and it appears what you are asking is possible.  However, the solution relies on an uncommon  usage of the PATCH function that I was not familar with until moments ago.  Let's do a mini-tutorial together Cat Very Happy 

 

Create a button and put this code in the OnSelect property.

Set(Person,{Name: "Milton", Address: "1 Main St"});

 

Next, create a new label called Label1 and put this code in the Text property.

Person.Address

 

The label will display this text string

1 Main St

 

Now create a 2nd button and put this code in the OnSelect property.

Set(Person, Patch(Person,{Address: "2 Main St"}));

 

Your label will now displaythis text string

2 Main St

 

I think this will do the trick.  Let me know if my proposed solution works for you!

 

FYI, here's the link to the MS documentation where I found the example. https://docs.microsoft.com/en-us/powerapps/maker/canvas-apps/functions/function-set

 

---
Please click "Accept as Solution" if my response helped to solve your issue so that others may find it more quickly. If your thought the post was helpful please give it a "Thumbs Up."

View solution in original post

Super User
Super User

Re: Updating a set variable before writing it to a new sharepoint item.

@mdevaney ,

 

Great reply.  

 

Thanks for the welcome.  I did a tremendous amount of development in Flow and Powerapps in the last couple of years.  I actually have both badges, for whatever thats worth.  The forums are amazingly helpful.  Actually, the documentation of these tools is so non-existent, or brief that forums have been the only way to get things done.  I'm amazed how folks have figured out how to do so many things.  Just like this statement you provided.  Just with using the documentation privided by MS, I would have never found out, except maybe by severe trial and error - or accident, how to write the statement as  you presented it.

 

I think I even remember having done this before, but I did not remember where, or how I did it.  Thanks for the fast and accurate reply!

 

Best Regards

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors
Users Online
Currently online: 333 members 6,430 guests
Please welcome our newest community members: