Often, when a real-time workflow is being executed in the background, users don’t know how long it will take for the processing to finish. setFormNotifications in D365 v9 come handy!
Here’s how I put my scenario –
- I call the Real-Time workflow using JS, example, on change of a certain field or the JS being called from the Ribbon button.
- The JS will trigger the Real-Time workflow I have.
Now, while the Real-time workflow is running, the user doesn’t know it has been called and should the user retry the same action? Here’s when the form notification is vital.
While the processing is happening, the message will remain as a notification on the form. Once the processing is complete, the notification will be cleared.
For the JS code implementation, the function to call the workflow needs ProcessJS which is available on https://github.com/PaulNieuwelaar/
- So on the Form, I’ll add my file after ProcessJS file.
- Here’s the Account Form code I wrote. I created a JS file to call the Real-Time workflow.
- In the above code, the Xrm.Page.ui.setFormNotification(Message, Type of notification, Unique Identifier); This will set the notification.
- Page.ui.clearFormNotification(UniqueIdentifier); will clear the notification from screen.
- Using this, When the Process enters in Processing mode, the message is shown on screen as “Please wait while processing”.
- And once the execution is finished successfully, the notification is cleared.
Similarly, you can even use this approach for WebAPI calls and have clearFormNotification set in the Success/Failure callbacks.
Hope this helps!