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

(0) ShareShare
ReportReport
Posted on by 31

Hello,

 

I am having trouble getting my Patch functions to work.  I have tried many different things I have read in forums including replacing the comas with semicolons, changing the variables to values, and removing the braces.  No matter what it says "The function 'Patch' has some invalid arguments. Here is the code: 

 

Patch(tblPass, First( Filter(tblPass,'Created By'.DisplayName = CurrentUser.DisplayName, Returned = false)), {tblPass.'Time Returned' : TimeNow})

// The declarations below are elsewhere in the app. I include just to show where the variables are coming from.
Set(CurrentUser,Office365Users.MyProfile())
Set(TimeNow,Now())
Categories:
I have the same question (0)
  • PavanKumar Profile Picture
    479 on at
    Hi, Give a try with the following expression and let me know if you still facing any issues. ClearCollect(colTblPass,First( Filter(tblPass,'Created By'.DisplayName = CurrentUser.DisplayName, Returned = false))); Patch(tblPass, First(colTblPass), {'Time Returned' : TimeNow}) ------------------------------------------------------------------------------------------- if this answers your question mark it as verified and give it a thumbsup Regards, Pavan Kumar Garlapati
  • Pstork1 Profile Picture
    69,026 Most Valuable Professional on at

    I see two potential issues

    1) When setting the value tblPass.'Time Returned' you don't need tblPass that is implied by the fact taht you are patching tblPass.  There is no way to patch a record from a different table.

    2) TimeNow will be a timespan variable.  Depending on what type of field Time Returned is you probably need to surround that value with some kind or reformatting to cast it to the appropriate data type. 

     

    I suspect your error is coming from #2.  What data type is the field you are patching?

  • aboucher Profile Picture
    31 on at

     


    @Pstork1 wrote:

    I see two potential issues

    1) When setting the value tblPass.'Time Returned' you don't need tblPass that is implied by the fact taht you are patching tblPass.  There is no way to patch a record from a different table.

    2) TimeNow will be a timespan variable.  Depending on what type of field Time Returned is you probably need to surround that value with some kind or reformatting to cast it to the appropriate data type. 

     

    I suspect your error is coming from #2.  What data type is the field you are patching?



    It is a date and time field in a SharePoint list.

  • aboucher Profile Picture
    31 on at

    @PavanKumar wrote:
    Hi, Give a try with the following expression and let me know if you still facing any issues. ClearCollect(colTblPass,First( Filter(tblPass,'Created By'.DisplayName = CurrentUser.DisplayName, Returned = false))); Patch(tblPass, First(colTblPass), {'Time Returned' : TimeNow}) ------------------------------------------------------------------------------------------- if this answers your question mark it as verified and give it a thumbsup Regards, Pavan Kumar Garlapati

    When you say "colTblPass" should that be replaced with the column name of the table tblPass?

  • PavanKumar Profile Picture
    479 on at
    Yes please also in the Time returned (i believe its a date field? if yes then use Today() Regards, Pavan Kumar Garlapati
  • aboucher Profile Picture
    31 on at

    @PavanKumar wrote:
    Yes please also in the Time returned (i believe its a date field? if yes then use Today() Regards, Pavan Kumar Garlapati

    Below is the code I am using.  I am now getting invalid argument type on both formulas.  I have tried it both with and without the single quotes.  The Time Returned field is a date time field.  I am more concerned with the time in that field than the date.  

    ClearCollect('Time Returned',First( Filter(tblPass,'Created By'.DisplayName = CurrentUser.DisplayName, Returned = false))); Patch(tblPass, First('Time Returned'), {'Time Returned' : Today()})
  • Verified answer
    Pstork1 Profile Picture
    69,026 Most Valuable Professional on at

    The single quotes are there because the field name has a space in it.

     

    I've duplicated your TimeNow variable and am able to save it without an issue.  But I don't have the Returned field in my test.  Is that a Yes/No column?

     

    Here's the formula that is working for me.

    Patch('Attendees List', First( Filter('Attendees List','Created By'.Email = User().Email)), { LastVisit: TimeNow})

    'Attendees list' is a SharePoint list and LastVisit is a DateTime column.  I'm using Email because it is more unique than display name, but the concept is the same.  You really don't need to retrieve the profile, just use User() which is the current user.

  • aboucher Profile Picture
    31 on at

    @Pstork1 wrote:

    The single quotes are there because the field name has a space in it.

     

    I've duplicated your TimeNow variable and am able to save it without an issue.  But I don't have the Returned field in my test.  Is that a Yes/No column?

     

    Here's the formula that is working for me.

    Patch('Attendees List', First( Filter('Attendees List','Created By'.Email = User().Email)), { LastVisit: TimeNow})

    'Attendees list' is a SharePoint list and LastVisit is a DateTime column.  I'm using Email because it is more unique than display name, but the concept is the same.  You really don't need to retrieve the profile, just use User() which is the current user.


    Yes, the Returned field is a Yes/No Column.  Here is the slightly modified version of your code that I am using.  I am getting "Invalid Argument Type".  Just for kicks, I also tried removing the Returned = false, and there was no change in the error.

    Patch(tblPass, First(Filter(tblPass, 'Created By'.DisplayName = CurrentUser.DisplayName, Returned = false)), {'Time Returned' : TimeNow})
  • aboucher Profile Picture
    31 on at

    Well, I figured out the issue.  I had more code attached to this button.  

    <code> &
    Patch(...) &
    <code>

    Does anyone know how to successfully execute another procedure on this button click?

  • Verified answer
    Pstork1 Profile Picture
    69,026 Most Valuable Professional on at

    Add semicolons to the end of each code line

    code;
    patch();
    code;

    Of course the actual character used may vary if you are international.  Check you localization settings.

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 531 Most Valuable Professional

#2
Haque Profile Picture

Haque 261

#3
Kalathiya Profile Picture

Kalathiya 221 Super User 2026 Season 1

Last 30 days Overall leaderboard