Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Return error message in plugin to action / JS

(0) ShareShare
ReportReport
Posted on by

Dear all,

I write a plugin to get page values and set some fields, and it is triggered by a custom ribbon button.  So I reference the following link https://www.greenbeacon.com/insights/trigger-plugin-from-ribbon-button-using-custom-actions-in-dynamics-crm-2013/ to create an action first and then write some javascript code as it said.  And I also register my plugin 'pre-operation' stage.

Its execution order should be Ribbon button > JS > Action > Plug-in

Now there are some custom error messages in my plugin, need to be shown up on the client side (maybe alert)

I tried to add InvalidPluginExecutionException("my error message.") in the plugin but I don't know how to get it in my javascript function.

Or should I add an output parameter in my action?  But I notice that if you want to get the output value in your action, you should only register plugin on 'post-operation' stage?

Thank you for your help.

*This post is locked for comments

  • RE: Return error message in plugin to action / JS

    Hi Nithya,

    thanks for your reply.

    I have to set values to fields and then do service.update(entity) in my plugin, that's why I register the plugin in pre-operation stage

    Is there another way to resolve this?

  • RE: Return error message in plugin to action / JS

    Hi Andrii,

    thanks for your reply.

    but it's another point that I have to set values to fields and then do service.update(entity) in my plugin so I register the plugin in pre-operation stage.

    If I register it in Post-Operation stage, updating doesn't work.

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: Return error message in plugin to action / JS

    Hi Yvonne,

    You can add an output parameter to your action with type string and set it to the alert you needed.

    Also, the output parameters can be set only in the post operation stage of the plugin.

    See: http://butenko.pro/2013/10/actions-usage-of-inputoutput-arguments-in-plugins-that-handle-actions/

  • Verified answer
    a33ik Profile Picture
    a33ik 84,325 Most Valuable Professional on at
    RE: Return error message in plugin to action / JS

    Hello,

    First thing - use Output Parameter.

    Second - register your plugin to work in Post-Operation stage and populate output parameter in it (population in pre-operation would not work).

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…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

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,407 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans