Use popup instead of a toast for backend validation messages
Hi,
I often use backend validation in Creatio - I prevent saving a record and throw an exception from an event listener. It works like a charm, but as a result, the end user sees only a toast message, which is small and disappears after a moment, so it's easy to overlook. Is it possible to intercept such an error and display a normal confirmation popup, instead of this one?
It would be great if there is a generic solution, which doesn't require me to change all of my validations.
Like
Hi Eryk, in your business process you can display a mini page with the process component pre-configured page.
Else you have following component to add in your site:
https://marketplace.creatio.com/template/popup-element-business-processes
Hope this helps.
Hello Eryk,
Thanks for your question.
As an alternative you can use websockets to implement your logic.
Here i created a custom section and a clientMessageBridge as described in this article. In this section i created a Test Field. To subscribe to message broadcasting in the HandleViewModelInitRequest handler i used schema attribute to store a function that will be called whenever a message is published. Also note, that you should unsubscribe from websocket connection when your view is destroyed. To do this please don't forget to implement such logic in HandleViewModelDestroyRequest handler.
On the form page when user clicks Save button a custom MyCustomRequest handler is called. In this handler i realized the following logic: call a business process (where i pass Test Field value as well as expected business process parameter value) -> if there is no validation error that is passed back from business process (hasValidationErrors property) i call SaveRecordRequest request -> if there is an error - the SaveRecordRequest is not performed.
Also the function that is triggered when a websocket message is broadcasted does open a pop-up which displays error message.
Here is an example:
And the outcome:
Hope this helps and let me know if you have any question left.