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 not wor...
Power Apps
Answered

Patch function not working with Lookup

(0) ShareShare
ReportReport
Posted on by 53

I am creating an editable grid which has a lookup column in it. This grid is a list of corrections that need to be done and the lookup column is connecting to the ID of a list of corrections.

 

I am trying to write a code that will add a new "line" to the correction sheet using the Patch function and I am getting an error.

Screenshot 2024-06-21 102346.png

It is not clear what the error is (I have tried changing what column the lookup column uses and it doesn't help and the ID is the best column for what I an doing). If anyone could help me with this that would be great.

Categories:
I have the same question (0)
  • ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    Hi @LR8 , Please check @RezaDorrani 's YT video: https://www.youtube.com/watch?v=76RJyaoW0BQ

    https://www.youtube.com/watch?v=wI6SHGQ9ATg&t=1936s

     

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    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.👍

    Thanks,
    ANB


  • LR8 Profile Picture
    53 on at

    I got this code from one of Reza Dorrain's (I love his videos) videos and for some reason it isn't working and that it what I am trying to figure out. 

  • ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    @LR8 Could you please confirm regarding 'Correction sheet number' column type? Is it lookup column?  Please try this:

    Patch('Correction sheet for Spec Check', 
     Defaults('Correction sheet for Spec Check'), 
     {
     'Correction sheet number': {
     Value: 'Correction List Gallery'.Selected.Value,
     ID: 'Correct List Gallery'.Selected.ID
     }
     }
    )

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    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.👍

    Thanks,
    ANB


     

  • LR8 Profile Picture
    53 on at

    @ANB I still get the error. You are correct 'Correction sheet number' is my lookup column

  • Verified answer
    ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    Hi @LR8 , Try with Id instead of ID

    Patch('Correction sheet for Spec Check', 
     Defaults('Correction sheet for Spec Check'), 
     {
     'Correction sheet number': {
     Value: 'Correction List Gallery'.Selected.Value,
     Id: 'Correct List Gallery'.Selected.ID
     }
     }
    )

     

    This should work. Please check this blog: https://www.matthewdevaney.com/power-apps-patch-function-examples-for-every-sharepoint-column-type/patch-a-sharepoint-lookup-column-in-power-apps/

     

    If this does not work then please share screenshot with error.

     

    -----------------------------------------------------------------------------------------------------------------------------

    I hope this helps.

    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.👍

    Thanks,
    ANB


  • Verified answer
    LR8 Profile Picture
    53 on at

    It still didn't work.

    I changed name of the lookup column from 'Correction sheet number' to 'Lookup from list' (so it is less confusing) and changed the look up column to connect to a title column instead of the ID column in the other list and now the following code works:

    Patch(
        'Correction sheet for Spec Check',
        Defaults('Correction sheet for Spec Check'),
        {
            'Lookup from list': {
                Value: 'Correction List Gallery'.Selected.Title,
                Id: 'Correction List Gallery'.Selected.ID
            }
        }
    );
     
    You were right the one ID needed to be written as Id. Thank you for all your help
  • ANB Profile Picture
    7,252 Super User 2026 Season 1 on at

    @LR8 Thats great! If my suggestion helped you to resolve your issue then please make sure to accept my suggestion as solution.

     

    Thanks,

    ANB

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 June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 326 Most Valuable Professional

#2
11manish Profile Picture

11manish 168

#3
sannavajjala87 Profile Picture

sannavajjala87 75 Super User 2026 Season 1

Last 30 days Overall leaderboard