Monday, January 14, 2019

Ability to Restrict a User to Create Folder through User Event Script

Currently users are able to create their own folders when attaching files to transactions, particularly for Purchase Requests. The objective is to restrict the permission for folder creation. Since the restriction on File Cabinet can only be made by Class, Department, Location and/or Group, this can be done through User Event on Before Record Submit.

Folder creation can be prevented for certain roles by creating a User Event on Before Record Submit. This User Event can then be deployed to the Folder record type. The following snippet illustrates this

*** START CODE ***var role = nlapiGetContext().getRole();if(role == 10){throw nlapiCreateError('NOT_PERMITTED', 'Your role does not allow you to create a folder');}*** END CODE ***

First, the code looks at the current user's role. If the user's role does not allow them to create folders, then you throw the error using nlapiCreateError(). This API is explained in detail in the following Help Guide link:

nlapiCreateError(code, details, suppressNotification)

No comments:

Post a Comment