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 in SharePoint wi...
Power Apps
Answered

Patch in SharePoint with a lookup to another list

(0) ShareShare
ReportReport
Posted on by 377

Hi 

I have two lists in SharePoint

Firms and Requests.

I have a column in Requests (called Firm) that is a lookup to Title in Firms.

I have a gallery galFirms and when an item is selected it changes the DropDownList ddSelectedFirm

 

How can I Patch to add a record to Requests

 

This gives me an error "Some invalid arguments" ....

 

Patch(Requests, Defaults(Requests), {Firm: ddSelectedFirm.Selected )

 

Thanks

P

Categories:
I have the same question (0)
  • LaurensM Profile Picture
    12,516 Moderator on at

    @pmwhelan patching a LookUp field to SharePoint works a little bit different.
    Could you check if this written tutorial solves your problem?

    That patch syntax should populate the LookUp field.

  • Verified answer
    WarrenBelz Profile Picture
    155,764 Most Valuable Professional on at

    Hi @pmwhelan ,

    Firstly Lookup columns will cause you a bit more grief than this - you might consider their use unless really necessary, but to your issue. As the code does not work I have to assume that the Items of ddFirm are not simply 

    Choices(Requests.Firm)

    so you need to "get back" the Id of the field which is actually the ID of the record in Firms matching the Title you looked up. What you will have is something like (NOTE Selected.Firm may be different depending on the Items of the drop-down)

    Patch(
     Requests, 
     Defaults(Requests), 
     {
     Firm: 
     {
     Value: ddSelectedFirm.Selected.Firm
     Id:
     LookUp(
     Firms,
     Title = ddSelectedFirm.Selected.Firm
     ).ID
     }
     }
    )

     

    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

     

  • pmwhelan Profile Picture
    377 on at

    Thanks

     

    So should it be ...

     

    Patch(Requests, Defaults(Requests), {Firm: Property:{
    '@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
    Id:1,
    Value:""
    } )

     

    That gives an error "Name isn't valid. Property isn't recognised"

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @pmwhelan,

    I see that @WarrenBelz has nicely written out the syntax and value logic for your case.

    Could you try that solution?

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 491

#2
WarrenBelz Profile Picture

WarrenBelz 407 Most Valuable Professional

#3
11manish Profile Picture

11manish 331

Last 30 days Overall leaderboard