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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / PowerApps patch(update...
Power Apps
Answered

PowerApps patch(update a record) beginner

(0) ShareShare
ReportReport
Posted on by

Goodday all(

, I am a beginner in PowerApps and i am also very new to the coding side of PA. I am trying to currently use a patch function to update my table.

DvdH_1-1673425825359.png


See example ERD of tables used.

I am trying to update table Three.
I want to insert Reason_Category.reason_category_id into table three. It is currently empty due to this being manually selected in the PowerApp i am making.
See below example of the powerapp.

DvdH_2-1673426285837.png


I want to insert reason_category_id into table 3 on submit button where two_name ='two_name_dropdown'.Selected.name

Any more data/information needed let me know.
Pseudo code in SQL style:

UPDATE table3
SET reason_category_id = id_reason_category_dropdown
WHERE two.name = two_name_dropdown.SelectedValue

 

 

I think i'd need something like shown below.

 

Patch(
'DD.two',
Lookup('two', name:'two_name_dropdown'.Selected.name),
{???:'???'.Text}
)

 

 

 

Any help/questions are welcome. I know this is a scattered post i am just very stuck.
Problem 2:
Another issue i can't seem to get the reason id correct.
in this instance reason cat 2 and 3 are empty and when empty instead of giving the reason id it gives a 1.
Any way to be garantueed to get the correct id? I am so confused by some of this.
See below:
DvdH_0-1673429220124.png

Categories:
I have the same question (0)
  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

     @Anonymous ,

     

    For the first issue:

     

    You mentioned you want to insert a new item in Three with the Patch function. To achieve that you need enter the Defaults function as the second argument:

     

    Patch(
     DD.Three,
     Defaults(DD.Three),
     {three_id: ____,
     SecondColumn: ____,
     LastColumn: ____}
    )

     

    More information on the Patch function can be found here: https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-patch

     

    I think the second issue got resolved here: https://powerusers.microsoft.com/t5/Building-Power-Apps/Dependant-dropdown-issue/m-p/1965537

  • Community Power Platform Member Profile Picture
    on at

    I am sorry i might not of explained it properly. I want to update a row in table two where two_id = two_id_dropdown.Selected.Value.
    I want to fill the empty column "reason_category_id" with reason_category_id_dropdown.Selected.Value where two_id = two_id_dropdown.Selected.Value.


    Thanks for all your support. This post is a bit older and some things have changed but this reply should make my problem clear.

  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

    Hi @Anonymous ,

     

    To update an exsting item in DD.Two where the two_id = two_id_dropdown.Selected.Value, and save the value of reason_category_id_dropdown.Selected.Value in the 'reason_category_id column', use:

    Patch(
     DD.Two, 
     LookUp(
     DD.Two,
     two_id = two_id_dropdown.Selected.Value
     ), 
     {reason_category_id: reason_category_id_dropdown.Selected.Value}
    )

     

     

  • Community Power Platform Member Profile Picture
    on at

     

    @BCBuizer Edited responds due to fixing error but finding different issues:
    For the submit button i got this issue:

    DvdH_0-1673881765817.png

    Patch(
     'DD.product_subunit_batch_step_timeloss', 
     LookUp(
     'DD.processorder_id',
     processorder_id = processorder_id_name_dropdown.Selected.processorder_id
     ), 
     {reason_category_id: input_reason_category_id.Text}
    )

    I at first didnt share any table names but i think these are fine. I confuse myself if i rename them so i will just use the names.

     

    DvdH_1-1673882162647.png

    The powerapp is connected to the data but might be write-only. How do enable permission for powerapps to edit tables in the database? I have admin rights to the sql server.

  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

    Hi @Anonymous,

     

    Usually there's no decimal in the Data Source name. The reason I left it in there is because that's what you provided and what seemed to be accepted in other topics. Try removing "DD.":

     

    Patch(
     processorder_id, 
     LookUp(
     processorder_id,
     full_processorder_id = processorder_id_name_dropdown.Selected.Value
     ), 
     {reason_category_id: input_reason_category_id.Text}
    )

     

  • Community Power Platform Member Profile Picture
    on at

    Hi i found the issue. At first i did try that and remove DD. but it is the table name. The ERD shown is not the actual table name since it was a moqup.
    I had to just put the table names in singuler quotes and it worked. Other issue was found. Can u check last post? I edited it.

  • BCBuizer Profile Picture
    22,505 Super User 2025 Season 2 on at

    Hi @Anonymous ,

     

    Good to read you got this issue resolved.

     

    For information on the new issue that appeared, please have a look around first before bringing it up in this topic. I found some suggestions for a similar error in this topic: https://powerusers.microsoft.com/t5/Building-Power-Apps/The-data-source-is-read-only-error/td-p/314639

  • Community Power Platform Member Profile Picture
    on at

    Thanks, i did find that post and i can create new rows with the connected account in the SQL location. This should mean that the account has the correct permissions i assume. If not how do i check it? I also refreshed all tables in the powerapps and i restarted the SQL management servers. Since this is how it was fixed for that topic i was hoping it would work for me aswell. Sadly it doesn't and i couldn't find where to see which account is connected. I think it is the admin account but would love to double check this. Also couldn't find where to see it on google.

  • Community Power Platform Member Profile Picture
    on at

    Thanks for your help. I will post an update of this post tomorrow. I am currently working from home and sick. My brain can not put this info together I think i've found the main problem with this patch run. I will repost about this tomorrow if i do not find anything online. If i find a solution myself i will post it aswell.
    Thanks @BCBuizer and anyone who read this.

  • Community Power Platform Member Profile Picture
    on at

    Good morning,
    I have looked into the issue and found it had to do with how the relationships are setup.
    I saw some issues with the code i had previously. New code:

     

    Patch(
     'DD.product_subunit_batch_step_timeloss', 
     LookUp(
     'DD.product_subunit_batch_step_timeloss',
     batch_cycle_id = dataholder_batch_cycle_id.Selected.batch_cycle_id
     ), 
     {reason_category_id: input_reason_category_id}
    )

     

    This fixed all errors except for the read-only error. I will try and look at this with the Database admin. Thanks i think this code above sorts the button though. I had to add some dependent dropdowns as data placeholders to be able to make this work.
    Apperently there were no specified PK's.
    I've fixed this.
    New error and the only error left:
    When i click the submit button while having all data spots filled i get this error. I only found where it says that people refreshed their powerapp and it was fixed this sadly did not fix it for me.

    DvdH_0-1674031982933.png

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 739 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard