Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

InvalidPluginExecutionException message to portal

Posted on by 815

I have a plugin that does some validation on a record create and displays a controlled message via the InvalidPluginExecutionException which displays the message to the CRM user. Unfortunately this controlled message is not displayed on the portal front end but a random exception message. Is there a way to display the message correctly on the portal front end

 

Thanks g

*This post is locked for comments

  • Suggested answer
    jestuder Profile Picture
    jestuder 156 on at
    RE: InvalidPluginExecutionException message to portal

    If it isn't running, it sounds like you aren't using an entity form but a web page.  The code snippet I provided is for validation of an entity form that is on a web page.  To do this on the web page without an entity form it would be:

    if (window.jQuery) {
        (function ($) {
            if (typeof (webFormClientValidate) != 'undefined') {
                var originalValidationFunction = webFormClientValidate;
                if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
                    webFormClientValidate = function () {
                        
                    };
                }
            }
        }(window.jQuery));


  • dhawal Profile Picture
    dhawal 260 on at
    RE: InvalidPluginExecutionException message to portal

    Hi James,

    I have used the above code however the below part doesn't fires. Is there any settings which we need to do? Please let me know as i am stuck on this. Quick help will be appreciated.

    entityFormClientValidate = function ()

           {

                      //DO VALIDATION HERE.  RETURN TRUE IF PASSED AND FALSE IF FAIL

                   };

  • vxan Profile Picture
    vxan 5 on at
    RE: InvalidPluginExecutionException message to portal

    Is there any other solution of handling the exceptions coming from plugins rather than re-implementing the same business logic in JavaScript? As long as you do not have the option to implement server side code this sounds very cumbersome!!! I would thought that the message of the plugin exception should be surfaced somehow in liquid or some other way that you can choose what to do next.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: InvalidPluginExecutionException message to portal

    Hi,

    I hope you are familiar with the adx portal code.

    Please check if you can put the try and catch block at the SaveChanges portion of code.

    The catch block must be returning you the error from plugin.

    You can capture this and write a custom javascript and display it to user.

    Hope this helped.

    Thanks

    Phanidhar

  • Suggested answer
    RaviKashyap Profile Picture
    RaviKashyap 55,410 on at
    RE: InvalidPluginExecutionException message to portal

    Hi,

    If there is an error/ exception then portal will always displays the generic error occurred. In your case, you are throwing exception with some custom message but to portals it is an exception.

    This is by design.

    As suggested above, you should look for ways to handle it within portal.

  • Verified answer
    jestuder Profile Picture
    jestuder 156 on at
    RE: InvalidPluginExecutionException message to portal

    Is the record being created from the portal?  If so, why not validate it before you create anything in crm?  Doing that will help prevent unclean data from getting into the system.  Validating the data before create in the portal can be done easily with JQuery and JavaScript

    if (window.jQuery) {
        (function ($) {
            if (typeof (entityFormClientValidate) != 'undefined') {
                var originalValidationFunction = entityFormClientValidate;
                if (originalValidationFunction && typeof (originalValidationFunction) == "function") {
                    entityFormClientValidate = function () 
    	        {
                       //DO VALIDATION HERE.  RETURN TRUE IF PASSED AND FALSE IF FAIL
                    };
                }
            }
        }(window.jQuery));
    }


    To output a message to the user on fail here is a code snippet that will work:

    $('.notifications').append($("<div class='notification alert alert-danger' role='alert'>PUT ERROR MESSAGE TEXT HERE</div>"));


    I do want to note that the first snippet of code will only validate on entity forms (entityFormClientValidate) if you need it to work on web forms then replace entityFormClientValidation with webFormClientValidate

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

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans