I have been using the throw new InvalidPluginExecutionException which prevent a record from being created upon a certain condition but now the customer just want a warning message displayed but the record created, Is there a way to just display a warning message instead of an exception from a plugin.
Your advice would be great.
Thanks G
*This post is locked for comments
Thanks Ben I had a feeling there was no simple way.
No the invalidpluginexception only handles errors - in which case the plugin will rollback the entire create / update transaction and an error message is displayed by Dynamics' front end.
Hence my statement that if you don't want the system to error with a message displayed you need to handle it in an entirely different way. One method is the one I suggested above which I have implemented in the past...
So this functions obviously in the event that you test this typically, however in the test environment it doesn't.
Regards: Maria Levis
I faced the similar issue with one of my customers. Unfortunately, there is no way you can make it look like a warning. InvalidPluginExecution exception does not accept any such custom arguments.
Thanks
Satish Reddy
Dynamics 365 Architect and Trainer
Sadly not, without some separate work as the user interface and backends are now very separated and the only time things propagate back up is for full errors.
You can however do it using the following:-
1) add a text field to the entity and make it a hidden field in the form
2) depending on the result of the plugin either set the field to be empty or put an error message in it.
3) Add some javascript that runs on page load (& reload when the page is saved) to check if the field has the alert message in it and if it does show the message.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156