cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
tupues
Helper III
Helper III

Patch single value in SP on button

Hi there,

 

I have a submit button for a form which on click I would like to:

 

- Submit filled form

- Clear the form

- write a value based on a selection in Dropdown1 in the title column of the SP list.

 

This is my code so far. Powerapps is complaining that the record is not correct...

 

Patch(Training_Feedback, Default, {Title: Dropdown1.Selected.Value});If(SubmitForm(Form1),NewForm(Form1))

 

 

Thanks for your help!

2 ACCEPTED SOLUTIONS

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @tupues ,

How do you submit your form data? Using SubmitForm function?

Is the Dropdown1 not the part of the Edit form?

Have you enable the "Title" field within your Edit form?

 

Based on the needs that you mentioned, I think the OnSuccess property of the Edit form could achieve your needs. Please take a try with the following workaround:

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

SubmitForm(Form1)

Set the OnSuccess property of the Edit form to following:

Patch(
      Training_Feedback,
      Form1.LastSubmit,
      {
         Title: Dropdown1.Selected.Value
      }
);
ResetForm(Form1);
Reset(Dropdown1)

or

Patch(
      Training_Feedback,
      LookUp(Training_Feedback, ID = Form1.LastSubmit.ID),
      {
         Title: Dropdown1.Selected.Value
      }
);
ResetForm(Form1);
Reset(Dropdown1)

 

If the Title field is a Required/Mandatory field in your SP List, you must enable the Title field in your Edit form, and provide a proper value for it when you use SubmitForm function to submit your form data.

If you do not enable the Title field in your Edit form, and want to submit your form data along the Title value (related to Dropdown1) back to SP List, I think the Patch function could achieve your needs. Please set the OnSelect property of the "Submit" button to following:

Patch(
      Training_Feedback,
      Defaults(Training_Feedback),
      Form1.Updates,
      {
         Title: Dropdown1.Selected.Value
      }
);
ResetForm(Form1);
Reset(Dropdown1)

 

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

 

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.

View solution in original post

Many thanks @v-xida-msft 

 

That last one did it! 

 

Thanks again and best regards,

 

Tom

View solution in original post

7 REPLIES 7
WarrenBelz
Super User
Super User

Hi @tupues ,

Firstly to patch a new record with only the title column

Patch(
   Training_Feedback, 
   Defaults(Training_Feedback), 
   {Title: Dropdown1.Selected.Value}
)

For a new form then

ResetForm(Form1);   //optional
NewForm(Form1))

Is this what you are trying to do?

 

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.

 

eka24
Super User
Super User

Insert 3 buttons:

1. SubmitForm(Form1) This is to submit your filled form

2. Reset(Form1) This is to clear your form

 

Hi @WarrenBelz 

 

Thanks for your help!

 

With this code:

 

Patch(
   Training_Feedback, 
   Defaults(Training_Feedback), 
   {Title: Dropdown1.Selected.Value}
)

 

I am getting the "behaviour function in a non behaviour property" error...

 

The dropdown value I am submitting is not part of the form as such but it should be treated as though it was... 

Hi @tupues ,

That code is the most basic new record Patch (see the second code in the overview on the Microsoft document). There is something else wrong here.

Firstly, is that the only code you are running with this? Also what is the Items property of your drop down?

v-xida-msft
Community Support
Community Support

Hi @tupues ,

How do you submit your form data? Using SubmitForm function?

Is the Dropdown1 not the part of the Edit form?

Have you enable the "Title" field within your Edit form?

 

Based on the needs that you mentioned, I think the OnSuccess property of the Edit form could achieve your needs. Please take a try with the following workaround:

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

SubmitForm(Form1)

Set the OnSuccess property of the Edit form to following:

Patch(
      Training_Feedback,
      Form1.LastSubmit,
      {
         Title: Dropdown1.Selected.Value
      }
);
ResetForm(Form1);
Reset(Dropdown1)

or

Patch(
      Training_Feedback,
      LookUp(Training_Feedback, ID = Form1.LastSubmit.ID),
      {
         Title: Dropdown1.Selected.Value
      }
);
ResetForm(Form1);
Reset(Dropdown1)

 

If the Title field is a Required/Mandatory field in your SP List, you must enable the Title field in your Edit form, and provide a proper value for it when you use SubmitForm function to submit your form data.

If you do not enable the Title field in your Edit form, and want to submit your form data along the Title value (related to Dropdown1) back to SP List, I think the Patch function could achieve your needs. Please set the OnSelect property of the "Submit" button to following:

Patch(
      Training_Feedback,
      Defaults(Training_Feedback),
      Form1.Updates,
      {
         Title: Dropdown1.Selected.Value
      }
);
ResetForm(Form1);
Reset(Dropdown1)

 

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

 

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.

View solution in original post

Many thanks @v-xida-msft 

 

That last one did it! 

 

Thanks again and best regards,

 

Tom

View solution in original post

@v-xida-msft I have to come back on this again - the patch works great. However now I don't get notification anymore if there is data missing or if the patch was successfully executed. Is there a way to add the alert in a smiliar fashion as in the conventional SubmitForm "success" command?

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

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.

Top Solution Authors
Users online (1,559)