cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mmchx
Helper IV
Helper IV

Patch function with Runtime error

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

 

 

8 REPLIES 8
Ramole
Super User
Super User

@mmchx 

 

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

Thank you
If this post helps, then Click on the Thumbs Up below. and Accept it as the solution . to help others find helpful.

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
Super User
Super User

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
Helper IV
Helper IV

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

 

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

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
Super User
Super User

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

 

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

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Check out the New Ideas Site

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (5,819)