Reallocate Item Page Restriction

MAR 682 Requirement

Restrict the employees from accessing the Reallocate Items page in Netsuite

Solution

This can be achieved by triggering a user event script on beforeLoad()


/*Version : 1.0
Script : User event script
Script Deployment: REALLOCATE ITEM
This script summarises that only allowed employees have access to reallocate items others are being restricted.

*/
//triggers on before loading the page
function beforeLoad()
{
// getting netsuite user internal id
var userid=nlapiGetContext().getUser();

//Searching employee record
var filters=new Array();
filters[0]=new nlobjSearchFilter('internalid',null,'is',userid);

var columns=new Array();
columns[0]=new nlobjSearchColumn('custentity_jj_mar_682_reallocate_item',null,null);

var search=nlapiSearchRecord('EMPLOYEE',null,filters,columns);

//Getting Search results
for(i=0;i<search.length;i++)
{
var status=search[i].getValue('custentity_jj_mar_682_reallocate_item');
break;
}
//Showing error if their checkbox status is False
if(status==="F")
{
throw nlapiCreateError('ERROR', "You have no access to the page");
}


}

Leave a comment

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