web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Patch function with Ru...
Power Apps
Unanswered

Patch function with Runtime error

(0) ShareShare
ReportReport
Posted on by 150

anyone has faced this issue?

I use the Patch function to create the list in SharePoint list, but faced this error. When I pressed the button, it didn't load anything and no error. I need to check on appchecker.

 

mmchx_0-1637877703683.png

 

 

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

    @mmchx 

     

    Can you share your currant formula so we can see the problem in text format please ? 

  • mmchx Profile Picture
    150 on at

    This one

    //patch the current leave day with the updated balance
    Patch(leaveTable,LookUp(leaveTable,Leave=Gallery_LeaveType.Selected.Title),{Days:LookUp(leaveTable,Leave = Gallery_LeaveType.Selected.Title,Days) - Totalleave });
    //patch sp list of the user latest balance
    Patch(CurrentUserBalance,LookUp(CurrentUserBalance,EmployeeName.Email = User().Email),{CurrentBalance:Concat(leaveTable,Days,";")});
    
    //patch record to the draft form
    Patch(LeaveRequest,Defaults(LeaveRequest),
     {Title: TitleInput.Text},
     {Startdate: StartDate.SelectedDate},
     {StartdateType: Dropdown_StartDate},
     {Enddate:EndDate.SelectedDate},
     {EnddateType:Dropdown_EndDate},
     {LeaveType:Gallery_LeaveType.Selected.Title},
     {Totaldays:Totalleave});
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @mmchx 

     

    #1. I assume the Current balance is a numeric field but I see a string with concat

    //patch sp list of the user latest balance
    Patch(CurrentUserBalance,LookUp(CurrentUserBalance,EmployeeName.Email = User().Email),{CurrentBalance:Concat(leaveTable,Days,";")});

     

    It should be

    //patch sp list of the user latest balance
    Patch(CurrentUserBalance,LookUp(CurrentUserBalance,EmployeeName.Email = User().Email),{CurrentBalance:Number});

     

    #2. Patch function for Draft from

    //patch record to the draft form
    Patch(LeaveRequest,
    Defaults(LeaveRequest),
     {
     Title: TitleInput.Text,
     Startdate: StartDate.SelectedDate,
     StartdateType: Dropdown_StartDate,
     Enddate:EndDate.SelectedDate,
     EnddateType:Dropdown_EndDate,
     LeaveType:Gallery_LeaveType.Selected.Title,
     Totaldays:Totalleave
    }
    );

     


    Thanks,
    Stalin - Learn To Illuminate

  • mmchx Profile Picture
    150 on at

    about the concat my currentbalance is a string.

    something like this 10;8;15;3 to collect the current balance of each type.

     

    The runtime error still occurs on the patch draft form

    mmchx_0-1637912466957.png

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @mmchx 

     

    I believe the error in LeaveType. If the leave type is Choice then try this

    //patch record to the draft form
    Patch(LeaveRequest,
    Defaults(LeaveRequest),
     {
     Title: TitleInput.Text,
     Startdate: StartDate.SelectedDate,
     StartdateType: Dropdown_StartDate,
     Enddate:EndDate.SelectedDate,
     EnddateType:Dropdown_EndDate,
     LeaveType: {Value: Gallery_LeaveType.Selected.Title},
     Totaldays:Totalleave
    }
    );

     

    If the problem continues then please let me know the Datatype for those fields to help further

     Title: SingleLne Text,
     Startdate: Date,
     StartdateType: ?,
     Enddate:Date,
     EnddateType:?,
     LeaveType:?,
     Totaldays: Number

     
    Thanks,
    Stalin - Learn To Illuminate

  • mmchx Profile Picture
    150 on at

    It stills has a problem.
    These are datatype of each field in my SharePoint list

     Title: SingLine Text,
     Startdate: Date,
     StartdateType: SingLine Text,
     Enddate:Date,
     EnddateType:SingLine Text,
     LeaveType:SingLine Text,
     Totaldays: Number
  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @mmchx 

     

    StartDateType and EndDateType are single-line text. And data comes from Dropdown. So this depends on the items property of the dropdown.

     

    Please try this.

    Patch(LeaveRequest,
    Defaults(LeaveRequest),
     {
     Title: TitleInput.Text,
     Startdate: StartDate.SelectedDate,
     StartdateType: Dropdown_StartDate.Selected.Value,
     Enddate:EndDate.SelectedDate,
     EnddateType:Dropdown_EndDate.Selected.Value,
     LeaveType: Gallery_LeaveType.Selected.Title
     Totaldays:Totalleave
    }
    );

     

    It could be 

    Dropdown_StartDate.Selected.Value

    or

    Dropdown_StartDate.Selected.Result

     

  • StalinPonnusamy Profile Picture
    Super User 2024 Season 1 on at

    Hi @mmchx 


    Please let us know if anything needs on your post. We can help with this.

    Please mark the post as Solved If I have answered your question.
    Please give it a Thumbs Up if you find the suggestion helpful

    Thanks,
    Stalin - Learn To Illuminate

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard