I have a button that runs an action which is a javascript snippet. This snippet returns a promise. It resolves the promise if successful and rejects it if it isn’t. I want to be able to add an onError action to the snippet action that will display the error message that is returned in the rejection of the promise.
I have the onError event working and it displays when the snippet code fails. The issue is, that it only displays the text that is put in the Message field of the action. Is there some sort of merge syntax I can use to pull out the text that I return from the rejected promise?
A few ideas.
1. Put the entire error message in your initial javascript snippet in the reject branch. This way you can pass variable text directly into the message.
2. If you really want to use a separate on error action - your reject branch could update a field with the value you want to show - and then you could use merge syntax to display the field value.
Thanks for the reply. I’ll probably end up using your 2nd idea. That’s probably cleaner from a ux perspective than showing the error through the block UI show message action.
Sounds good. Hope it works for you
Any property passed in as a parameter to the Deferred.reject() is available in template syntax in the onError Message, so:
dfd.reject({message : 'This is a message that the user will see.'});
Will block the UI and display the message passed in to the reject call to the user.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.