Patch Function Returning Server Error
-
Patch Function Returning Server Error
Posted by DSC Communities on February 22, 2019 at 7:02 am-
Sheryl Darroch
MemberFebruary 22, 2019 at 7:02 AM
I have a PowerApp that I am building for a customer. I have split the form between multiple screens and used buttons to simulate tabs at the top of the screens, so to the user it looks like they are just moving between tabs. I have a save button on every screen, which uses a patch function to save all the (84) fields of the form to my SharePoint list.It worked for a while, then I started getting a server error. I fixed that error when I realized that one of my SharePoint column names was misspelled (how it worked prior to that, I have no idea).
Then the customer requested that I switch two of the fields from lookup fields to multiple lines of text fields. Easy, right? Text fields are so much easier to patch than lookups. Wrong, when I made the change the pesky server error returned. Then, I read something that reminded me if you have required fields, you have to patch them every time, or you will get an error (my Patch function actually didn’t include the three required fields, because they are not editable once they are entered the first time). So, I added the required fields to my patch function, hoping that would fix the error. It didn’t.
I have also tried the whole “remove the data source and re-add it” solution that I have read a gazillion times in my searching for a solution. That didn’t work either.
I’m completely at a loss, and wondering if I will ever be able to deliver my product to my customer. Below is my patch function. (I set the variables and the collection in the same on-select property within a Concurrent function prior to the patch function.) I would greatly appreciate any suggestions. Thanks in advance for taking the time to read this rather lengthy request. š
Patch(BI_Projects,First(Filter(BI_Projects,Title=TitleControl.Text)),{Title: ETitle.Text,Location:{‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,Id: varLocation,Value: ELocation.Selected.Value},Area:{‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,Id: varArea,Value: EArea.Selected.Value},‘Project Description’: EProjectDescription.Text,TeamLead: {‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,Claims: First(collTeamLead).Claims,Department: First(collTeamLead).Department,DisplayName: First(collTeamLead).DisplayName,Email: First(collTeamLead).Email,JobTitle: First(collTeamLead).JobTitle,Picture: First(collTeamLead).Picture},TeamMembers: ETeamMembers.SelectedItems,ProjectType: {‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,Id: varProjectTypeID,Value: EProjectType.Selected.Value},‘IT Enabled?’: EITEnabled.Value,CurrentYearImpact: {‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,Id: varCurrentYearImpactID,Value: ECurrentYearImpact.Selected.Value},ImprovementOutcome: {‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,Id: varImprovementOutcomeID,Value: EImprovementOutcome.Selected.Value},ImpactVersusEffort: {‘@odata.type’: “#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference”,Id: varImpactVersusEffortID,Value: EImpactVersusEffort.Selected.Value},‘CapitalRequired?’: ECapitalRequired.Value,‘CapitalApproved?’: ECapitalApproved.Value,AFE_Number: EAFENumber.Text,AFE_ApprovalDate: EAFEApprovalDate.SelectedDate,PlannedStartDate: EPlannedStartDate.SelectedDate,PlannedCompletionDate: EPlannedCompletionDate.SelectedDate,ValueGenerationDate: EValueGenerationDate.SelectedDate,Milestone1: EMilestone1.Text,Milestone1ExpectedCompletion: EMilestone1ExpectedCompletion.SelectedDate,Milestone1Comments: EMilestone1Comments.Text,Milestone2: EMilestone2.Text,Milestone2ExpectedCompletion: EMilestone2ExpectedCompletion.SelectedDate,Milestone2Comments: EMilestone2Comments.Text,Milestone3: EMilestone3.Text,Milestone3ExpectedCompletion: EMilestone3ExpectedCompletion.SelectedDate,Milestone3Comments: EMilestone3Comments.Text,Milestone4: EMilestone4.Text,Milestone4ExpectedCompletion: EMilestone4ExpectedCompletion.SelectedDate,Milestone4Comments: EMilestone4Comments.Text,Milestone5: EMilestone5.Text,Milestone5ExpectedCompletion: EMilestone5ExpectedCompletion.SelectedDate,Milestone5Comments: EMilestone5Comments.Text,Milestone6: EMilestone6.Text,Milestone6ExpectedCompletion: EMilestone6ExpectedCompletion.SelectedDate,Milestone6Comments: EMilestone6Comments.Text,Milestone7: EMilestone7.Text,Milestone7ExpectedCompletion: EMilestone7ExpectedCompletion.SelectedDate,Milestone7Comments: EMilestone7Comments.Text,Milestone8: EMilestone8.Text,Milestone8ExpectedCompletion: EMilestone8ExpectedCompletion.SelectedDate,Milestone8Comments: EMilestone8Comments.Text,Mielstone9: EMilestone9.Text,Milestone9ExpectedCompletion: EMilestone9ExpectedCompletion.SelectedDate,Milestone9Comments: EMilestone9Comments.Text,Milestone10: EMilestone10.Text,Milestone10ExpectedCompletion: EMilestone10ExpectedCompletion.SelectedDate,Milestone10Comments: EMilestone10Comments.Text,BaseCase: EBaseCase.HtmlText,VendorsConsidered: EVendorsConsidered.Text,VendorsSelected: EVendorsSelected.Text,SummaryOfImprovementsMade: ESummaryOfImprovementsMade.HtmlText,ActualStartDate: EActualStartDate.SelectedDate,ActualCompletionDate: EActualCompletionDate.SelectedDate,Safety: ESafety.Text,SafetyUnit: ESafetyUnit.Text,‘Safety Close Out Year’: Value(ESafetyCloseOutYear.Text),‘Safety-LOM’: Value(‘ESafety-LOM’.Text),CostReduction: ECostReduction.Text,CostReductionUnit: ECostReductionUnit.Text,CostReductionCurrentYear: Value(ECostReductionCurrentYear.Text),‘CostReduction-LOM’: Value(‘ECostReduction-LOM’.Text),RevenueIncrease: ERevenueIncrease.Text,RevenueIncreaseUnit: ERevenueIncreaseUnit.Text,RevenueIncreaseCurrentYear: Value(ERevenueIncreaseCurrentYear.Text),‘RevenueIncrease-LOM’: Value(‘ERevenueIncrease-LOM’.Text)});——————————
Sheryl Darroch
Developer / Office 365 Consultant
Lake Orion MI
—————————— -
Will Page
MemberFebruary 25, 2019 at 2:06 AM
Instead of patching, trigger a flow that has an action to get item, then update item and finally return some info to the app so you know it succeeded. Using a flow to update your SP list seems way more reliable than patching the data source.——————————
Will Page
Technical consultant
+64210436716
——————————
——————————————- -
Sheryl Darroch
MemberFebruary 26, 2019 at 9:22 AM
Will,Thanks for the suggestions. I was trying to avoid introducing Flow into the mix as it is outside of the scope of work, but it is starting to look like this is a route I may have to consider.
——————————
Sheryl Darroch
Developer / Office 365 Consultant
Lake Orion MI
——————————
——————————————- -
Shon Newton
MemberFebruary 26, 2019 at 12:45 AM
It seems like instead of simulating tabs with multiple screens it would be easier to handle all of this on one screen with tabs and then you would only have to patch one time and the user could easily navigate the different tabs to edit data.This video does a quick rundown of how to create a tabbed form in PowerApps with either the Form Control/Data Cards and Submit Form or using the new GroupBy Control and the Patch Function.
https://www.youtube.com/watch?v=aA3gqmo1xzw&t=2s——————————
Shon Newton
——————————
——————————————- -
Sheryl Darroch
MemberFebruary 26, 2019 at 9:24 AM
Thanks for the suggestion. I originally had it set up like this, but was running into all kinds of issues with positioning the fields on the screen.——————————
Sheryl Darroch
Developer / Office 365 Consultant
Lake Orion MI
——————————
——————————————-
DSC Communities replied 6 years, 6 months ago 1 Member · 0 Replies -
-
0 Replies
Sorry, there were no replies found.
The discussion ‘Patch Function Returning Server Error’ is closed to new replies.