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 / Issue Patching to Shar...
Power Apps
Answered

Issue Patching to SharePoint Lookup column

(0) ShareShare
ReportReport
Posted on by 116

Hi all, Can anyone see what I am doing incorrectly here? I have the following code:

 

 

With(
 {
 existingBooking: First(colExistingCardBookings)
 },
 If(CountRows(locAvailableCards) = 0,
 UpdateContext({locExtendDateError: "Error message here"}),
 //Otherwise assign the first Available card to the existing booking
 Patch('Card Booking Requests', existingBooking, 
 {Card:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
 Id:First(locAvailableCards).ID,
 Value:First(locAvailableCards).'Reference Number'}
 }
 )
)
 )

 

What I am trying to do is the following:

I have two SharePoint lists, one for cards and one for bookings. The Bookings list has a lookup column to allow association of a card to a booking.

 

In the code above I need to assign a new value to the Card column for an existing Booking record if there is one in the Available Cards list.

However I keep getting the following error:

 

rdorman_0-1666098620149.png

I'm pretty sure it's the Patch call, as if I replace the Patch call with empty quotes the error disappears, but I can't for the life of me see what is wrong with the Patch call. 

 

 

 

Categories:
I have the same question (0)
  • theapurva Profile Picture
    970 Super User 2024 Season 1 on at

    Hello @rdorman ,
    According to error, Card column seems to be bollean,
    Can you check the Column type in Sharepoint List?

    If you recently updated it to Lookup up, Please refresh the datasource in Powerapps and then Try.

  • CU16050836-1 Profile Picture
    116 on at

    Thanks for the suggestion. The column is definitely a lookup column:

    rdorman_0-1666099889945.png

    and I have been working on this app for quite a while so the data source is not new to the app, nor has it recently changed.

  • Verified answer
    theapurva Profile Picture
    970 Super User 2024 Season 1 on at

    Got it, 
    true block of If is returning true /false and false block of If i.e. Patch is returning record, so its giving error.
    thus just add IsBlank outside your Patch.
    this should definitely work:

    With(
     {
     existingBooking: First(colExistingCardBookings)
     },
     If(CountRows(locAvailableCards) = 0,
     UpdateContext({locExtendDateError: "Error message here"}),
     //Otherwise assign the first Available card to the existing booking
     IsBlank(Patch('Card Booking Requests', existingBooking, 
     {Card:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference",
     Id:First(locAvailableCards).ID,
     Value:First(locAvailableCards).'Reference Number'}
     }
     ))
    )
     )

      

  • CU16050836-1 Profile Picture
    116 on at

    Thank you so much, that seems to have fixed it. You are a lifesaver!

  • theapurva Profile Picture
    970 Super User 2024 Season 1 on at

    Glad to know that I could help You. 🙂

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 529 Most Valuable Professional

#2
Haque Profile Picture

Haque 230

#3
Kalathiya Profile Picture

Kalathiya 217 Super User 2026 Season 1

Last 30 days Overall leaderboard