cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Issue with Formula-level error management setting

I am getting the following error when trying to patch a Sharepoint list when the app setting for "Formula-level error management" is on.

FormulaLevelErrorManagement.PNG

The error results from the following Patch statement:

Patch(MyIssues
If(varIssue.ID = -1, {ID: Blank()}, {ID: varIssue.ID}),
{
Requester: varIssue.Requester,
Title: varIssue.Title
}
)

 

If I switch off "Formula-level error management", I do not get an error.

I had this App Setting on because I needed to save blank dates to the Sharepoint list, which I remember reading was only possible with this option on.

3 REPLIES 3
Super User
Super User

Re: Issue with Formula-level error management setting

@Anonymous 

In general, your patch formula has some issues.

You should not be trying to set the ID of a SharePoint item.

Your formula should look like this:

Patch(MyIssues,
  If(varIssue.ID = -1, Defaults(MyIssues), Lookup(MyIssues, ID=varIssue.ID)),
  {
    Requester: varIssue.Requester,
    Title: varIssue.Title
  }
)

In order for the Patch to work properly, you need a data source/Collection, a Record to Patch, and the changes to make.  

If you are creating a new item in a SharePoint list, you need to use the Defaults function on that list as the Record to Patch. 

If you are patching and existing, then you need to look up the record to patch.

The Patch statement and SharePoint will handle the ID, you should never try to set it yourself.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Anonymous
Not applicable

Re: Issue with Formula-level error management setting

Hi @RandyHayes,

 

I appreciate your response, but that makes no difference. I still get the error using the syntax you suggest (and mine also works fine if I switch off Formula-level error management).

I am not setting the ID, I am identifying the record, following various posts such as https://baizini-it.com/blog/index.php/2018/01/11/powerapps-replace-the-defaults-function-to-improve-...

 

Super User
Super User

Re: Issue with Formula-level error management setting

@Anonymous 

So, in general, setting the ID on a new list item to Blank() is not a good idea unless you absolutely know your datasource will only require that field.  But, yes, if that is the only important field, then the syntax will work as the article suggests.

It seems you are having an issue outside of that general formula.

 

Try doing a simple Patch(MyIssues, Defaults(MyIssues), {Requester: "Test", Title:"Test"}) and see if it works fine.

If so, then try Patch(MyIssues, {ID:Blank()}, {Requester:"Test", Title:"Test"}) and see if that works.

If so, then go all the way with Patch(MyIssues, {ID:Blank()}, {Requester:varIssue.Requester, Title:varIssue.Title}) and see if there is an issue there.

 

One of those might start to point to the issue.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (4,950)