Custom Errors

There are two ways to return an error to any specific users/ roles eg: a scenario to restrict access to certain records but cannot take out their permission from the user/ role set up.

  1. Use “Return User Error” action in Workflow – whick acts on loading a record (beforeLoad in script terms)
  2. In User Event Script use the following code beforeLoad/beforeSubmit (on loading/on submitting a record)

Code Snippet

var myCustomError = error.create( {
                        name: 'NO_PERMISSION',
                        message: 'No permission.......',
                        notifyOff: false
                    } );
                    log.error( 'Error: ' + myCustomError.name, myCustomError.message );
                    throw myCustomError;

Points to note while using the Scripting Method:
– Avoid try-catch
– Specify the Context only as ‘User Interface’ in the Context filtering otherwise it may block other script actions etc.

Leave a comment

Your email address will not be published. Required fields are marked *