web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Specific increment of ...
Power Apps
Answered

Specific increment of a column linked to a form

(0) ShareShare
ReportReport
Posted on by 68

I am faced with a seemingly simple problem but on which I am stuck, I want to increment by 1 the value of a specific column of the record linked to the form when it is submitted with "OnSuccess". So far I have managed to accomplish this task using the code :

 

UpdateIf(OffreGeneree;
ID = ThisRecord.ID;
{Modifications: Value(Label19.Text)+1})

 

However, the increment result affects all records in my data source, whereas I want it to only apply to the record associated with the current form. Any idea how to solve this problem?

 

Thanks in advance

Categories:
  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Hi @Emilbou ,

    Firstly you need to refer to the field that that Label is reading from rather than the Label with something like this

    Patch(
     OffreGeneree;
     {
     ID: Self.LastSubmit.ID;
     Modifications: Self.LastSubmit.Modifications + 1
     }
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Emilbou Profile Picture
    68 on at

    Thanks for your help.
    I tried your methodology and although I understand the logic, the increment recreates a different line. Here I modified offer n°10389 three times and the three increments were done independently

    Emilbou_0-1714453125300.png

     

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    @Emilbou ,

    You did not state your data source and I assumed SharePoint for the exercise (which it seems it is not) - try this

    Patch(
     OffreGeneree;
     Self.LastSubmit;
     {Modifications: Self.LastSubmit.Modifications + 1}
    )

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Emilbou Profile Picture
    68 on at

    I am indeed playing on SharePoint data, I apologize for the oversight. the last methodology that you advised me does not work, the increment is not taken into account anywhere.

  • Verified answer
    WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    Hi @Emilbou ,

    OK I must be misunderstanding something - if you are running thecode OnSuccess of a Form and the DataSource of the Form is OffreGeneree, then this

    Patch(
     OffreGeneree;
     {
     ID: Self.LastSubmit.ID;
     Modifications: Self.LastSubmit.Modifications + 1
     }
    )

    should patch to the same record as has just been submitted (I use the syntax regularly in prod apps). You can be a bit more specific like this

    With(
     {_Mods: Self.LastSubmit.Modifications};
     Patch(
     OffreGeneree;
     {
     ID: Self.LastSubmit.ID;
     Modifications: _Mods + 1
     }
     )
    )

    but the first one should work.

     

    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.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • Emilbou Profile Picture
    68 on at

    I'm currently working with a SharePoint database and customizing a PowerApps form. My goal is to make it so that after each change to an item, the "Modifications" value increments by 1. Initially, I planned to use the onSuccess event to automatically increase the "Modifications" value of 1. I thought that since modifications start from 0, I wouldn't need to define separate instances for modification and creation.

     

    However and I don't know why, I'm having issues with both of your approaches where the form keeps creating new rows instead of updating existing ones. Additionally, using LastSubmit worries me, because unless I'm mistaken it might only capture the last saved value if I need to modify an old version.

  • Emilbou Profile Picture
    68 on at

    I also tried to use the LookUp function, although I don't like using this function in the case of a large data set, to correctly target and increment my element like this:

     

    Patch(
    OfferGenerated;
    LookUp(OfferGenerated; ID = Self.LastSubmit.ID);
    {Modifications: Self.LastSubmit.Modifications + 1})

     

    But even in this way, my value does not change. what surprises me is that I imagined it would be simpler to target the active element on which the form operates.

  • WarrenBelz Profile Picture
    156,528 Most Valuable Professional on at

    @Emilbou ,

    I am not sure what to say here other than all the versions should work. Self.LastSubmit when used OnSuccess of a Form simply identifies the record the Form has just saved. The only thing here that may be an issue is that it is an Integrated Form and you are using the built-in OnSave event. To test this theory, try the code on an icon instead.

  • Emilbou Profile Picture
    68 on at

    I just managed to do what I wanted in a not very clean but functional way I guess.
    I got around the problem of identifying the active record by putting the ID field in the form but visible: false, I then compared in an updateIF the id of the element and that of my DataCardValue like that :

     

    UpdateIf(
     OffreGeneree;
     ID = Int(DataCardValue2.Text);
     {Modifications: Label19.Text +1})

    However, I managed to apply your method on a button as advised, now that I know it works, I will try to integrate it into the form controls, thank you very much for your time

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard