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.
- Use “Return User Error” action in Workflow – whick acts on loading a record (beforeLoad in script terms)
- 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.