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 / Patch function working...
Power Apps
Answered

Patch function working inconsistently with Dataverse

(0) ShareShare
ReportReport
Posted on by 52

Hello

I've created an app from a dataverse table
In this app there's a gallery and a form, selecting an item in the gallery changes the form to show the selected item, so far so good.
However i want to be able to incrementally change the value of a single datacard and then submit it back to dataverse, for context this is to quickly change the amount of stock on a given item. 

I've tried using the following patch function on a button seperate to the form 

Patch(
Varelager;
LookUp(
Varelager;
'På lager' = RecordsGallery1.Selected.'På lager'
);
{'På lager': RecordsGallery1.Selected.'På lager' + 1}
)

Varelager is the Dataverse Table, 'På Lager' Is the column, and RecordsGallery1 is the gallery that you select items from.

I've assigned this to a button outside the form to be able to independently change that specific value, however it sometimes doesn't work with a single click, and requires multiple presses. I have tried to troubleshoot with Powerapps Monitoring, but as far as I can tell it works as intended, I've also tried seeing if it's a problem with updating the shown value, it is not. 
Any suggestions on how to fix the patch function, or other methods of achieving the same thing would be greatly appreciated

Have a nice day!
Thanks in Advance.
Tobias

Categories:
I have the same question (0)
  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @TobiasSQA - it seems illogical that you want to incrementally change the stock column, but you're also using the stock column as the as the Lookup condition to return the record to Patch.

     

    On another note, if you're using a Form, is there a specific need to use Patch as opposed to updating the Update property of the DataCard to:

     

    Value(DataCardValue1.Text) + 1

     

  • TobiasSQA Profile Picture
    52 on at

    Hello @Amik 
    Thanks a lot for your response

    I should have clarified, I need to also be able to increment it down, so -1 and +1, without having to submit the entire form.

    So I believe changing the update function on the DataCard would not work, I also do not understand how I would "update" the datacard to create that change. 

    Thanks in Advance.

  • Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @TobiasSQA - I am assuming the Patch statement correctly updates the Dataverse field, but the change is not reflected in the Form? What do you have in the Item property of that Form?

     

    Back to my earlier comment, is there a reason your patching the stock column AND using that column in your LookUp condition within the same procedure?

  • TobiasSQA Profile Picture
    52 on at

    Hello

    The change is not reflected anywhere, it just randomly sometimes works, and sometimes doesn't, sometimes it's 3 presses on the button, sometimes it's 1
    The item property of the form is simply "RecordsGallery1.Selected"

    As for the patching, I have literally no reason as to why I'm doing that, that's just the only way I could get it to work. 
    Any suggestions to changing the patch function would be great

    Attached is a gif showing my problem

    Also note that it is not a problem of it just not updating, as you can see it goes up by increments of 1 no matter what I do, so that part works fine. and using monitoring it does spit out the desired number, but for some reason it simply gets lost when trying to patch it to dataverse.

    PowerappsExampleVideo.gif
  • Verified answer
    Ami K Profile Picture
    15,687 Super User 2024 Season 1 on at

    @TobiasSQA ,

     

    Please try: 

     

    Patch(
     Varelager,
     RecordsGallery1.Selected,
     {
     'På lager': RecordsGallery1.Selected.'På lager' + 1
     }
    )

     

  • TobiasSQA Profile Picture
    52 on at

    Hey Amik, sorry for the late reply

    I could've sworn I tried this exact one when going through all the options, but I guess I did not, or I failed miserably at formatting it. 
    Thanks a lot for the help, saved the day! 

    Kind Regards
    Tobias S Q 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard