cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Post Prodigy
Post Prodigy

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
Highlighted
Post Prodigy
Post Prodigy

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!

Highlighted
Community Support
Community Support

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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

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

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (6,884)