cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
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
Highlighted
Super User III
Super User III

@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.
Check out my PowerApps Videos too!
Highlighted
Anonymous
Not applicable

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-...

 

Highlighted

@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.
Check out my PowerApps Videos too!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (11,376)