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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (95,798)