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

Patch error handling key conflict

Is there a way to catch a key conflict error rised by dataverse in order to present a user friendly error to the user instead of the long technical generic message of key conflicts?

I have an entity E on Dataverse with a key constraint composed by 2 fields A,B. Currently when I patch a record in E if dataverse incurs in a key conflict it raises an excelption causing a long technical message to be prompted to the user.

I would like to catch this error in order to prompt a more user friendly message to our user.

With this in mind I wrote the following snippet of code:

 

Patch(E,myRecord,{A:"myValueA",B:"myValueB"});
If(
     IsEmpty(
        Errors(
           E,
           myRecord
       ),//doStuff

       Notify("My User friendly message",Error)
)

 

how can I handle the exception rised by the Patch formula in order to grab the message and substitute it with a more user friendly message?

1 ACCEPTED SOLUTION

Accepted Solutions
___Pool___
Frequent Visitor

I implemented a workaround: for not incurring in the key conflict error I am fatching the record before patching it

 

UpdateContext(
{
      recordAlreadyExists: CountIf(
          E,
     A=myrecord.A && B=myRecrod.B
) = 0
}
);

then I am patching the update just in case the variable recordAlreadyExists is false.

 

Let me know if you can find another way to accomplish this

View solution in original post

1 REPLY 1
___Pool___
Frequent Visitor

I implemented a workaround: for not incurring in the key conflict error I am fatching the record before patching it

 

UpdateContext(
{
      recordAlreadyExists: CountIf(
          E,
     A=myrecord.A && B=myRecrod.B
) = 0
}
);

then I am patching the update just in case the variable recordAlreadyExists is false.

 

Let me know if you can find another way to accomplish this

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

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