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

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
Resident Rockstar
Resident Rockstar

@mmchx 

 

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

Thank you
If this post helps, then please consider Accept it as the solution to help the others and consider giving it a "Thumbs Up."

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
Community Champion
Community Champion

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

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
Community Champion
Community Champion

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
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,512)