Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

adding payload to code activity exception

Posted on by

i'm writing a PCF that calls a code activity.

in the ode activity i want to throw exceptions of 2-3 types and i want to differentiate between them with a simple condition

is it possible to add errorType, or any other field to the exceptions returned from the code activity? is there any documentation on this?

thank you

  • Verified answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: adding payload to code activity exception

    The challenge here is that you don't have control over the code that is returned and you can set the message returned only.

    That is why I used this approach to differentiate between different issues that could occur at the backend.

  • liranelisha Profile Picture
    liranelisha on at
    RE: adding payload to code activity exception

    hmmm... that means all the calls to the backend return 200, even though some of them are failures, right?

    is this the best practice in dynamics?

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: adding payload to code activity exception

    Hello,

    I usually use the following approach:

    1. In the action or custom api (I believe this is what you are talking about) I introduce new properties like "Success (bool)", "ErrorMessage (string)".

    2. When something goes wrong in the codebehind I just set Success to false and pass ErrorMessage that contains the description of what exactly wrong.

    3. Use Success/ErrorMessage in clientside code.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans