Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

plugin is triggered by workflowaction - how to handle exception in plugin

(0) ShareShare
ReportReport
Posted on by 72

Hi Community!

I have a complicated situation.

On a form on entity A in CRM 2016 a workflowAction is triggered by clicking on a ribbon-button (via javascript)

In this workflowAction an entity B (totally different type) is updated. On this entity a plugin is registered (only on update). This plugin itself calls a webservice. If webservice-call fails the first workflowaction has to handle this but shouldn't throw an error.

If i throw an InvalidPluginExecutionException in plugin for entity B if webservicecall fails I get "There is no active transaction....." 

I also need the failed message the webservice returns, to show what happened, to the user.

How can I handle this?

thx in advance

©a-x-i

  • nyiicco Profile Picture
    nyiicco 10 on at
    RE: plugin is triggered by workflowaction - how to handle exception in plugin

    The web service call executes first before you update entity B. Before you execute the update, you can check first the response code of the web service, if the code is not "200" means there is an error encountered. So instead of proceeding with the update, save the web service response to other entity which the user can check.

  • Axi Bachlechner Profile Picture
    Axi Bachlechner 72 on at
    RE: plugin is triggered by workflowaction - how to handle exception in plugin

    thank you for your reponse.

    The problem is, that I don't want to save entity B if the webserviceCall wasn't successful. So an exception is the only way to trigger a rollback.

    a-x-i

  • PabloCRP Profile Picture
    PabloCRP 1,088 on at
    RE: plugin is triggered by workflowaction - how to handle exception in plugin

    Hi,

    base on how it's build your solution, I wouldn't trow an exception in the plugin, unless a core functionality failed, but for know what happed with the external webservice I'd log in entity B the Response, could be in one memo field and then with the javascript validate the status of the response and like if the response has a status different from 200 then show the body of the response. here and example of what the plugin would log.

    {
    "statuscode":200, //400,401,etc. 
    "message":"All done!"//Your data it's wrong, no authorized, etc.
    }

    regards.

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans