cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Submit Form with Patch together

Hello Everyone,

I am new to Power Apps. I need to know on how to submit a form and patch a record together.

 

I have a question. Is it possible to submit a form and on the same formula to patch a column which I want to update?
I just want to update one column with multiple data with a comma separator which is saved in a collection.



5 REPLIES 5
stephybabes
Helper I
Helper I

hey! I had this same question not so long ago.

Put your patch formula in the "OnSuccess" property of your form 🙂

This means you can use form1.lastsubmit.id to tell the patch function which record you want to patch! When the record already exists! Else it doesn't exist yet!

Hope this helps 🙂

Anonymous
Not applicable

Hello @stephybabes 
Can you please explain with an example? It would be very helpful.
Thanks in advance !!

timl
Super User
Super User

Hi @Anonymous 

@stephybabes suggestion offers a simple solution.

The thing I would add is that because calling the SubmitForm and Patch will incur 2 separate data operations, I would suggest that it's more efficient for to call just either SubmitForm, or Patch.

On your form, you can add a hidden card and set the update property to the formula that generates the comma separated values from your collection.

If you prefer to use the Patch approach, you can call patch and pass the form updates and the additional value that you want to patch.

Patch(yourDataSource, 
      recordToAddOrUpdate,
      Form1.Updates,
      {colum:"your additional value to patch"}
)

 

Sure.

So you have a form that adds an item to your sharepoint list. Let's call it Form1 and List1.

You also have a button that submits the form.

Your button's "OnSelect" property needs to be SubmitForm(Form1).

You also want to add more data to this sharepoint list item that your form doesn't ask the user for, am I right?

If so, you want the form to create the item, then when it has successfully created the item, to patch on some extra data from somewhere else that isn't the form, yes? 

So you would select the "OnSuccess" property of form1. 

And you would put:

Patch(List1,Form1.LastSubmit.ID,{column1: value1})

Where value1 might be anything.

Tell me more about the column you are wanting to add multiple values from a collection to.

Anonymous
Not applicable

Hello @stephybabes & @timl , Thank you for your reply.

I have written this in my submit button :

Patch(
ItemsCollect,
Defaults(ItemsCollect),
{Technology: DataCardValue3.Text}
);
ForAll(
Gallery1.AllItems,
Collect(
ItemsCollect,
{Technology: TextInput2.Text}
)
);
Patch(
EmpDetails,
Defaults(EmpDetails),
{
EmpID: Value(DataCardValue2.Text),
'Name (Title)': DataCardValue1.Text,
Department: DataCardValue5.Selected,
Technology: Concat(
ItemsCollect,
Technology,
", "
)
}
);

SubmitForm(SharePointForm1);
Clear(ItemsCollection);
Clear(ItemsCollect);
ResetForm(SharePointForm1);
NewForm(SharePointForm1);

I want to save the form in the sharepoint list, where Technology has multiple values. 
My form has a Technology data card and I have created an ADD button to add more technologies into the Technology column, which I am trying to save it from the Patch function.

Here is the view of my App : 

NewToEveryThing_0-1644326986285.png

 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (2,314)