cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
simms7400
Level 8

How to patch from EditForm.Mode = New ?

Hi Folks -

 

I have a PowerApps application with a SharePoint List source.  I have a field called "Element_Type" that I have a default value set to "FALSE".  Upon a new request, I have a dialogue box pop-up and based on their selection of what type of data element they are creating, I need to populate "Element_Type" with a value of "TRUE".

 

How do I use the patch feature to update a new request being submitted to SharePoint? For existing rows it seems easy but directly from a button that isn't associated to a datacard I'm having trouble.

 

I need to update table "rdInvestments" column "Element_Type" to "TRUE" upon a button selection.

 

Can someone help me? THank you!!!

2 REPLIES 2
simms7400
Level 8

Re: How to patch from EditForm.Mode = New ?

Here are the contents of my button:

Patch(rdInvestments,Defaults(rdInvestments),{Device_Flag:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",Id:1,Value:"TRUE"}});NewForm(InvestmentEditForm) && Navigate(InvestmentEditScreen,ScreenTransition.None);UpdateContext({boolPopUpOwnership: false})

The above code patches to the list correctly) but it creates a new record, then it nevaigate to the new form and when I submit that, it creates ANOTHER record.

 

My goal is to change  Device_Flag to TRUE upon navgating to my new form for the new record i'm tryin to create.  As the value of TRUE will drive visibility and required fields.

 

Thank you!

Community Support Team
Community Support Team

Re: How to patch from EditForm.Mode = New ?

Hi @simms7400 ,

Could you please share a bit more about the Device_Flag field in your SP List? Is it a LookUp field or a Choice type field?

Do you want to update the Device_Flag field of the Submitted record from your form into TRUE value?

 

Based on the needs that you mentioned, I think there is something with your formula. The Patch formula you provided above could be only used to create a new record in your SP List rather than update existing record.

 

According to the needs you mentioned, I think the OnSuccess property of the Edit form and Patch function could achieve your needs. I have made a test on my side, please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following:

 

SubmitForm(InvestmentEditForm);

Set the OnSuccess property of the InvestmentEditForm to following:

 

Patch(
       rdInvestments,
LookUp(rdInvestments, ID = InvestmentEditForm.LastSubmit.ID),
{
Device_Flag: {
'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
Id:1,
Value:"TRUE"
}
} );
NewForm(InvestmentEditForm);
Navigate(InvestmentEditScreen, ScreenTransition.None);
UpdateContext({boolPopUpOwnership: false})

Please consider take a try with above solution, then check if the issue is solved.

Note: The OnSuccess property of Edit form would be fired when you submit your Edit form data successfully.

 

Best regards,

 

 

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

Helpful resources

Announcements
Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

thirdimage

Power Apps Community User Group Member Badge

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

sixthImage

Join THE global Microsoft Power Platform event series

Attend for two days of expert-led learning and innovation on topics like AI and Analytics, powered by Dynamic Communities

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Microsoft Business Applications Virtual Launch

Join us for the Microsoft Business Applications Virtual Launch Event on Thursday, April 2, 2020, at 8:00 AM PST.

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,344)