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 Apps
Answered

Lookup Patch

(0) ShareShare
ReportReport
Posted on by 156

I'm trying to find for the latest data for the patch function to update in sharepoint but i can't seem to get it to work. It just updates the first data with the right person(s) full name. Does anyone know how do i solve this issue?

 

The following is the code that I'm currently using:

 

Set(currentItem,Patch(eLeaveApp, LookUp(eLeaveApp, 'Employee Name' = User().FullName ),{'SV Status': "Cancelled"},{'HOD Status':"Cancelled"},{'Admin Status':"Cancelled"}))

Categories:
  • Verified answer
    mdevaney Profile Picture
    29,993 Moderator on at

    @gimar01 
    Your syntax should be changed to the code below.  The squiggly brackets should contain all of the columns you want to change as a single record.

    Set(
     currentItem,
     Patch(
     eLeaveApp,
     LookUp(eLeaveApp, 'Employee Name' = User().FullName ),
     {
     'SV Status': "Cancelled",
     'HOD Status': "Cancelled",
     'Admin Status' :"Cancelled"
     }
     )
    )

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • gimar01 Profile Picture
    156 on at

    it still doesn't update the data inside it though, that's the main thing I want that is not working

  • mdevaney Profile Picture
    29,993 Moderator on at

    @gimar01 
    Two possibilities exist:

    #1 - if no updates have been made its may be because this code did not find any record to update.

    LookUp(eLeaveApp, 'Employee Name' = User().FullName )

     

    You can check if its finding a record by temporarily using this code in a label.  If it returns TRUE it found a record.  If it returns FALSE it did not.

    !IsBlank(LookUp(eLeaveApp, 'Employee Name' = User().FullName))


    #2 - if no updates have been made it may be because you are using Choices columns in SharePoint.  Your code looks like this:

    'SV Status': "Cancelled"


    Instead it should look like this:

    'SV Status': {Value: "Cancelled"}



    For more info on how to PATCH Choices columns go here:
    https://matthewdevaney.com/power-apps-patch-function-examples-for-every-sharepoint-column-type/patch-a-sharepoint-choices-column/

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • gimar01 Profile Picture
    156 on at

    It does reply true and no they are text type data, not a choice data. I double checked before entering it. Is there any more possibilities?

  • mdevaney Profile Picture
    29,993 Moderator on at

    @gimar01 
    How are you checking that the data was updated?  Please describe all the steps you are taking.

  • gimar01 Profile Picture
    156 on at

    Basically, when a user enters a data through a form. The app will patch it into a sharepoint list which will be accessible to other apps which are correlated to it. If the user decides to cancel their request, the app will find for the last record and cancel it as they can only cancel the latest record and not the ones before it. It worked before I put the 'currentItem' code but it'll update the wrong data, it updates the first data which is the same name as the 'User()' command. I want it to find for the last made record by the user and update the columns to 'Cancelled'.

  • Verified answer
    WarrenBelz Profile Picture
    156,956 Most Valuable Professional on at

    Hi @gimar01 ,

    I will throw my 20c in here if it helps.

    The key here is that you after the latest record belonging to the user. Also User().FullName is not Delegable (nor is First), so try this

    UpdateContext({varUser:User().FullName});
    With(
     {
     wUserID:
     Sort(
     Filter(
     eLeaveApp,
     'Employee Name'=varUser
     ),
     ID,
     Descending
     ).ID
     },
     Set(
     currentItem,
     Patch(
     eLeaveApp, 
     {ID:First(wUserID)},
     {
     'SV Status': "Cancelled",
     'HOD Status':"Cancelled"
     'Admin Status':"Cancelled"
     }
     )
     )
    )

     

    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.

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 232 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 202 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 122

Last 30 days Overall leaderboard