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

Not able to properly update a record using updateContext

So, I have a context variable that is a record saved when you select an item from a gallery. here is the code:

Navigate('Edit Ticket', ScreenTransition.Fade, { itemToEdit: Gallery9.Selected, IsEditSelected:true });
ViewForm(EditForm3);

All good and fine, when the form is loaded the info is there as ThisItem Item in the form is set to "itemToEdit".
Problem is that I have a button that when clicked should update itemToEdit.Status, which is a choice field from sharepoint list.
So if I try to use UpdateContext with Patch:

UpdateContext({ itemToEdit: Patch(itemToEdit, { 'Status': { Value: "In Progress" } }) }) 

 

After that the form simply breaks, I can't view the data and the patch won't work either. Are there any other ways to do that (update status) instead of creating a separated variable just for the Status?

Changing the choice directly from the form would also work for me. Just not sure how yet.

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User
Super User

Re: Not able to properly update a record using updateContext

Hi @rssilvaba ,

You cannot Patch a Variable - only a Collection or Table/List. I will give you a start on this as below. First part

Navigate(
   'Edit Ticket', 
   ScreenTransition.Fade,
   {IsEditSelected:true}
);
ClearCollect(
   colEditItem,
   Gallery9.Selected
)

and the second

Patch(
   colEditItem,
   First(vEditItem),
   {
      'Status':
      {
         Value: "In Progress"
      } 
   }
)

The Item for your form would be

First(colEditItem)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

1 REPLY 1
Highlighted
Super User
Super User

Re: Not able to properly update a record using updateContext

Hi @rssilvaba ,

You cannot Patch a Variable - only a Collection or Table/List. I will give you a start on this as below. First part

Navigate(
   'Edit Ticket', 
   ScreenTransition.Fade,
   {IsEditSelected:true}
);
ClearCollect(
   colEditItem,
   Gallery9.Selected
)

and the second

Patch(
   colEditItem,
   First(vEditItem),
   {
      'Status':
      {
         Value: "In Progress"
      } 
   }
)

The Item for your form would be

First(colEditItem)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

View solution in original post

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (4,249)