web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
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

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    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).

  • Verified answer
    Nithya Gopinath Profile Picture
    17,078 on at

    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/

  • Community Member Profile Picture
    on at

    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.

  • Community Member Profile Picture
    on at

    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?

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans