cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
simms7400
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
simms7400
Post Prodigy
Post Prodigy

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!

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,864)