Showing results for 
Search instead for 
Did you mean: 
Not applicable

Submits two forms possible due to Patch() Function



I have an app in which we store data for possible projects. In this we have fields in which "Win Ratio" is added, client name etc etc.


My issue is that when I add a NEW (not when I edit existing) it adds a new form ONLY consisting the inserted Win Ratio. The Win Ratio DataCardValue has a Patch() function in the OnChange property as I need it to update so that I can calculate in another field. I suspect this is the issue, but do not know how to figure out how to solve this problem. I have added a screenshot below so that you can see the two newly added items in the gallery:




These were added at the same time. The first ONLY contains the Win Ratio which I intended to add when I submitted the AAA client.


When I edit the Win Ratio field in the editform (New form) it gives the dots above, which shows how it is saving/updating:





I have tried deleting and readding and manually writing the Patch again. The Patch() in the Onchange of the Win Ratio is:


Patch(Maintable_SPM, ThisItem,{'Win Ratio': Value(DataCardValue40.Text)})
Super User II
Super User II

If you want to write some new info into a collection / datasource using Patch you need to use something like:


PATCH(collection,defaults(collection), {item; item})


The code you've used refer only to an existing record.


To solve the problem, you can also use smthg like:

PATCH(collection, if (is_new_item,defaults(collection),thisitem), {item; item}).


Not applicable

 @gabibalaban , thank you for the response!


Being new I am a bit confused with your formula, I made it like this, but it gives me an error:


Patch(Maintable_SPM, If(NewForm(Defaults(Maintable_SPM),ThisItem), {'Win Ratio': Datacardvalue40})



Super User II
Super User II

Sorry, now i saw that you are using FORM. Can you try with SubmitForm.

The PATCH function is nou usable in these circumstances.

Not applicable


I think it already saves it the moment I enter a win ratio, that seems to be the issue. The screenshot in my first post shows how it is updating the form when I enter the win ratio
Not applicable

The problem seems to arise when I use the Value(DataCardValue40.Text). In the Patch() function:


Patch(Maintable_SPM, ThisItem, {'Win Ratio': Value(DataCardValue40.Text)})


But I need to use Value(.Text) because otherwise it gives me an error:


"Server Response: A value most be provided for Item. ClientRequestID: xxxxxxxxxxxxxxxxxxxxxx"

Not applicable

@gabibalaban @mdevaney @CarlosFigueira 

If any of you can help me.


I have now 100% found the problem. It is basically as my latest post suggest due to the fact that different fields have Patch() formulas in them.


Below I have a NEWFORM/EDITFORM in which I give the AccountName, Phase, Client Budget, Win Ratio and Duration in Days:





When I finally submit, I find 5 new items in my gallery:





1. The correct form with all the data

2. Only containing the Phase

3. Only containing the Win Ratio

4. Only containing Client Budget

5. Only containing the duration in days



All of those fields each have a Patch() function so that the monthly average will be immediately calculated. The functions are:



FOR PHASE:         Patch(Maintable_SPM, ThisItem, {Phase: DropdownPhase.Selected.Phase})

FOR CLIENT BUDGET: Patch(Maintable_SPM, ThisItem,{'Client Budget': Value(ClientBudgetDataCardValue.Text)})

FOR WIN RATIO:    Patch(Maintable_SPM, ThisItem,{'Win Ratio': Value(WinRatioDataCardValue.Text)})

FOR DURATION IN DAYS: Patch(Maintable_SPM, ThisItem,{'Duration in Days': Value(DurationDaysDataCardValue.Text)})



I need to add the Value(XXXXX.Text) for the patch function, otherwise I get an error everytime I change the data in the form:


"A value must be provided for item"


EDIT: I should mention this does NOT happen when I EDIT an existing item.

The patch code you have there is ONLY for editing an existing item. To create a new you use:


Patch(SPList, Defaults(SPList), {Title: TextInput.Text, Column2: TextInput.Text})


You need something that looks to see if it is new or an edit (a variable or if statement) and use the code you have when it is an edit and the other when it is creating a new entry.


You are correct in that fact that you will have to use the Value(TextInput.Text) -- anytime you have a number column of any sort you will need to use that.

Not applicable


Thank you for the response.


Can you guide me a little how I would integrate that into the current patch formula I have?


I am using an Excel Maintable. I assume that is not a problem?


If this is the patch function for the client budget, how do I integrate the patch function for a new form?:


Patch(Maintable_SPM, ThisItem,{'Client Budget': Value(ClientBudgetDataCardValue.Text)})


I normally do SharePoint list, not excel...I find it works better with PowerApps so I'm not sure about the differences there. Is this all going to one place or you have two different worksheets you are posting to?


Also, that Patch part you put above that you are using...did you split that out just to show here or that is what you are using because that can be combined to:


Patch(Maintable_SPM, ThisItem,
{Phase: DropdownPhase.Selected.Phase, 'Client Budget': Value(ClientBudgetDataCardValue.Text, 'Win Ratio': Value(WinRatioDataCardValue.Text), 'Duration in Days': Value(DurationdaysDataCardValue.Text)})


Only reason you would do it split is if you are using something besides the "Maintable_SPM"


Helpful resources

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!


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 (26,650)