cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SabineR
Frequent Visitor

IfError not working with Patch

Hello,

 

I have 2 questions about the feature IfError():
1st one: can you confirm that, even it's still an experimental feature,  IfError() won't be deprecated in the future, but it's still an experimental feature as you are working on its improvement? 

 

2nd one: I try to implement it when inserting/updating a Sharepoint list with Patch().
I tried to test it by Patching a new item with one required field empty, but it failed:
the IfError() doesn't work and the item is registered in the list with the mandatory field empty.

Is there any additional configuration we must do on the Sharepoint list?

The code is basic:

IfError(Patch(table1,Defaults(table1),{....})

    , [...sending email with error detail...]

    ) 

 

Many thanks in advance for your help,

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi @SabineR 

 

Sending email if any error

 

Patch(
     'DataSource',
     Defaults('DataSource'),
     {
         TestName: "Test"
     }
 );
 If(
     !IsEmpty(Errors('DataSource')),
    Office365Outlook.SendEmailV2(
        "EmailId",
        "Error has Occured",
        Concat(Errors('DataSource'), Column&": "&Message),
        {Importance: "High"}
    ),
     Navigate('OtherScreen');
 )

 

Note: Make sure to add Office365Outlook as Data source

View solution in original post

4 REPLIES 4
StalinPonnusamy
Super User
Super User

Hi @SabineR 

 

Here is the same one for Error handling

 

Patch(
     'Test Scores',
     Defaults('Test Scores'),
     {
         TestName: txt_TestName.Text
     }
 );
 If(
     !IsEmpty(Errors('Test Scores')),
     Notify(
         Concat(Errors('Test Scores'), Column&": "&Message),
         NotificationType.Error
     ),
     Navigate('Success Screen');
 )

 

 Note: You can update yours. Instead of notification, we can send an email.

 

StalinPonnusamy
Super User
Super User

Hi @SabineR 

 

Sending email if any error

 

Patch(
     'DataSource',
     Defaults('DataSource'),
     {
         TestName: "Test"
     }
 );
 If(
     !IsEmpty(Errors('DataSource')),
    Office365Outlook.SendEmailV2(
        "EmailId",
        "Error has Occured",
        Concat(Errors('DataSource'), Column&": "&Message),
        {Importance: "High"}
    ),
     Navigate('OtherScreen');
 )

 

Note: Make sure to add Office365Outlook as Data source

SabineR
Frequent Visitor

Hi @StalinPonnusamy , thank you for your 2 messages. 

As the 2 solutions, IfError() and Errors(), exist, is Errors() the more appropriate for Error handlings from Sharepoint?

 

Kind regards,

Sabine

 

 

 

 

 

StalinPonnusamy
Super User
Super User

Hi @SabineR 

 

Possible to get multiple errors. So we concatenate the errors and display them. This should work for a single error as well. So better to handle multiple whenever possible.

 

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

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