Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Show custom pop up message when plugin complete task

(2) ShareShare
ReportReport
Posted on by 2,453
Hi Everyone
Is there a way to show a message once the plugin complete a task- success or fail message. For example "Document created successfully!"
  • Suggested answer
    Amit Katariya007 Profile Picture
    Amit Katariya007 8,596 Super User 2024 Season 1 on at
    Show custom pop up message when plugin complete task
    In Dynamics 365, plugins run server-side, so they don't have direct access to the user interface to display messages. However, you can achieve this functionality using one of the following approaches:
     
    1. Use a Custom Action and Synchronous Workflow/Plugin
     
    Create a custom action that triggers your plugin logic.
    Call this action from a JavaScript web resource or through Power Automate.
    Return the success or failure message as part of the action's response.
    Display the message to the user using JavaScript on the form or a dialog.
     
    Steps:
     
    1. Create a custom action in the Dynamics solution.
    2. Register the plugin on the custom action's execution.
    3. Use JavaScript to call the action and handle the response.
    4. Show error message using openAlerDialog api.
     
     
    2. Throw Exceptions in Plugin
     
    If the plugin fails, you can throw an exception with a user-friendly error message. Dynamics will display the error to the user.
    For successful operations, this method doesn't work, as no "success message" mechanism exists for plugins.
     
    Example:
     
    if (operationFailed)
    {
        throw new InvalidPluginExecutionException("Document creation failed due to invalid data.");
    }
     
    3. Use a Real-Time Workflow/Flow to Update a Field
     
    Update a custom field (e.g., "Status Message") on the record with the success or failure message after the plugin completes.
    Add a notification or JavaScript logic to display the message when the field is updated.
     
    Steps:
     
    1. Create a custom text field on the entity (e.g., statusmessage).
    2. Update the field from your plugin with the desired message.
    3. Use form scripting to display the field's value as a notification.
     
    var statusMessage = formContext.getAttribute("statusmessage").getValue();
    if (statusMessage) {
        Xrm.Navigation.openAlertDialog({ text: statusMessage });
    }
     
    4. Create a InApp Notification.
    You can create a InApp Notification from plugin it self. So no need of Any Client side code.
     
     
    Which Approach to Choose?
     
    Simple error messages: Throw exceptions in the plugin.
    Interactive success and error messages: Use Custom Actions or Custom APIs with JavaScript.
    Record-level feedback: Update a field with the message and display it using form scripting.

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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans