cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
bolin-stratus
Level: Powered On

Patch Unknown Error - Save Custom Form to SharePoint List

I am using patch to save data from a custom form to SharePoint list.  After executing this code, it fails to insert a new item in the last. When I return to the code, I see that red lines indicating there is an issue but with the generic message "Unknown error".  My data matches my SP list columns (all SP columns are text input data types). 

 

First, how do I execute this where I can test if it passed or failed and how would I retrieve the error? 

 

Patch( 'New Teams Pursuit Sites', Defaults('New Teams Pursuit Sites'), { 'Title': txtPursuitName, 'Pursuit-Name': txtPursuitName, 'SFDC-ID': txtSFDCID, 'Site-Owners': txtSiteOwners, 'Members': txtMembers, 'Financials': radFinancialsOption.Selected.Value, 'Additional-Instructions': txtAdditionalInstructions } );
1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Patch Unknown Error - Save Custom Form to SharePoint List

Hi @bolin-stratus ,

Yeah, you are right. You should modify your formula as below:

Patch(
'New Teams Pursuit Sites',
Defaults('New Teams Pursuit Sites'),
{
'Title': txtPursuitName.Text,
'Pursuit-Name': txtPursuitName.Text,
'SFDC-ID': txtSFDCID.Text,
'Site-Owners': txtSiteOwners.Text,
'Members': txtMembers.Text,
'Financials': radFinancialsOption.Selected.Value,
'Additional-Instructions': txtAdditionalInstructions.Text
}
)

Note: If you do not append a .Text to the txtPursuitName, txtSFDCID, txtSiteOwners, ..., PowerApps would recognize the txtPursuitName, txtSFDCID, txtSiteOwners, ... as controls rather than Text value.

 

In addition, do you want to capture the error message when the patch formula does not execute propertly? Based on the needs that you mentioned, I think the Errors() function could achieve your needs. Please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following formula:

If(
    !IsEmpty(
Errors(
'New Teams Pursuit Sites',
Patch(
'New Teams Pursuit Sites',
Defaults('New Teams Pursuit Sites'),
{
'Title': txtPursuitName.Text,
'Pursuit-Name': txtPursuitName.Text,
'SFDC-ID': txtSFDCID.Text,
'Site-Owners': txtSiteOwners.Text,
'Members': txtMembers.Text,
'Financials': radFinancialsOption.Selected.Value,
'Additional-Instructions': txtAdditionalInstructions.Text
}
)
)
),
Nofity("Your Patch function is not executed properly, the data is not saved into your SP List!", NotificationType.Error), /* <-- Show fail error message when your Patch function is not executed properly */
Nofity("Your Patch function executes successfully!", NotificationType.Success) /* <-- Show a success message when your Patch function executes successfully */ )

More details about the Errors function and Notify function, please check the following article;

Errors function

Notify function

 

Please take a try with above solution, then check if the issue is solved. If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
2 REPLIES 2
bolin-stratus
Level: Powered On

Re: Patch Unknown Error - Save Custom Form to SharePoint List

Easy fix. I needed to add .Text to the text input fields. 

 

Patch( 'New Teams Pursuit Sites', Defaults('New Teams Pursuit Sites'), { 'Title': txtPursuitName.Text, 'Pursuit-Name': txtPursuitName.Text, 'SFDC-ID': txtSFDCID.Text, 'Site-Owners': txtSiteOwners.Text, 'Members': txtMembers.Text, 'Financials': radFinancialsOption.Selected.Value, 'Additional-Instructions': txtAdditionalInstructions.Text } );

 

However, I'd still like to know how to determine a pass/fail error message in this context if data save doesn't properly execute.

Community Support Team
Community Support Team

Re: Patch Unknown Error - Save Custom Form to SharePoint List

Hi @bolin-stratus ,

Yeah, you are right. You should modify your formula as below:

Patch(
'New Teams Pursuit Sites',
Defaults('New Teams Pursuit Sites'),
{
'Title': txtPursuitName.Text,
'Pursuit-Name': txtPursuitName.Text,
'SFDC-ID': txtSFDCID.Text,
'Site-Owners': txtSiteOwners.Text,
'Members': txtMembers.Text,
'Financials': radFinancialsOption.Selected.Value,
'Additional-Instructions': txtAdditionalInstructions.Text
}
)

Note: If you do not append a .Text to the txtPursuitName, txtSFDCID, txtSiteOwners, ..., PowerApps would recognize the txtPursuitName, txtSFDCID, txtSiteOwners, ... as controls rather than Text value.

 

In addition, do you want to capture the error message when the patch formula does not execute propertly? Based on the needs that you mentioned, I think the Errors() function could achieve your needs. Please take a try with the following workaround:

Set the OnSelect property of the "Submit" button to following formula:

If(
    !IsEmpty(
Errors(
'New Teams Pursuit Sites',
Patch(
'New Teams Pursuit Sites',
Defaults('New Teams Pursuit Sites'),
{
'Title': txtPursuitName.Text,
'Pursuit-Name': txtPursuitName.Text,
'SFDC-ID': txtSFDCID.Text,
'Site-Owners': txtSiteOwners.Text,
'Members': txtMembers.Text,
'Financials': radFinancialsOption.Selected.Value,
'Additional-Instructions': txtAdditionalInstructions.Text
}
)
)
),
Nofity("Your Patch function is not executed properly, the data is not saved into your SP List!", NotificationType.Error), /* <-- Show fail error message when your Patch function is not executed properly */
Nofity("Your Patch function executes successfully!", NotificationType.Success) /* <-- Show a success message when your Patch function executes successfully */ )

More details about the Errors function and Notify function, please check the following article;

Errors function

Notify function

 

Please take a try with above solution, then check if the issue is solved. If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

Follow PowerApps on Twitter

Stay Up-to-Date by following PowerApps on Twitter

Top Community Contributors for July 2019

Top Community Contributors for July 2019

Let's thank our top community contributors

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

FifthImage

Dynamics 365 and Power Platform April 2019 Release notes

Features releasing from April 2019 through September 2019!

Users Online
Currently online: 56 members 4,269 guests
Please welcome our newest community members: