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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

showing messages from a plugin

(0) ShareShare
ReportReport
Posted on by 500

Hi guys

please tell me how to stop a save and show a javascript alert from a pre-stage plugin.

Thanks in Advance,

Lasa

*This post is locked for comments

I have the same question (0)
  • duchan2 Profile Picture
    6 on at

    hi,
    You can throw exception from your plugin.  

    throw new InvalidPluginExecutionException("Message text");

    this will stop save&close operation and show text "Message text" in dialog box.

  • lasa jay Profile Picture
    500 on at

    Hi Dusan,
    you are right but there are some other probs with this solution, lets say i wanna continue with  the save and then show an alert.Problem is when you throw this exp after an insert and then try to save again (hit save again after the popup from the same screen) it actually inserts duplicate records.
    so im just wondering whether theres other ways of accomplishing this.

    Regards,

    Lasa

     

  • Jeremy Winchell Profile Picture
    1,165 on at

    Your best course of action here is to use a plug-in, some OnLoad() javascript and a couple attributes.

    1. Create 2 attributes:  new_showerror (bit), new_error(nvarchar or ntext)

    2.  If your plug-in encounters an error populate these 2 fields as part of the PreCreate or PostCreate plug-in, depending on when you want it to fire.

    3. In the OnLoad()

    if(crmForm.FormType == 1) && (crmForm.all.new_showerror.DataValue == true)
    {
    //Then use window.alert or window.confirm to display the message.
    //Once the alert is acknowledged or the confirm dialog is acted upon you can then set the new_showerror to false which will prevent the alert from showing back up the next time the form is loaded.
    }

  • lasa jay Profile Picture
    500 on at

    Hi Jeremy,

    thats exactly what i ended up doing, I dont think theres any other way to accomplish this.

    Also i had to update the obj from the plugin in order to set the error msg. 

    Regards,

    Lasa

  • Saddamk206 Profile Picture
    777 on at

    Hi, 

    We can throw an exception and display a message.

    throw new InvalidPluginExecutionException("Message here....");

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans