To create a custom alert that is thrown when a user logs in through a specific role, we can use a custom portlet that calls a portlet script that checks the users role and send the alert.
Below is a sample script that checks the role of the user and throws an alert if it matches.
function reminderPortlet(){
portlet.setTitle('Custom Reminder Portlet');
var role = nlapiGetRole();
if (role=='10'){
var searchFilters = new Array();
searchFilters[0] = new nlobjSearchFilter('salesrep', null, 'anyof', nlapiGetUser());
var searchResult = nlapiSearchRecord('customer',null,searchFilters, null);
var customer = '';
var spacer = ' , ';
for (var i=0; i<searchResult.length; i++){
if (i<(searchResult.length-1)){
spacer = ' , ';
}else{
spacer = '';
}
var custObj = nlapiLoadRecord('customer',searchResult[i].getId());
customer = customer + custObj.getFieldValue('entityid')+' : '+custObj.getFieldValue('companyname')+spacer;
var url_customer = nlapiResolveURL('RECORD', 'customer', searchResult[i].getId());
var customer_list = customer_list + '<a href="'+url_customer+'">'+customer+'</a></br>';
}
}
var htmlPage = '<script>alert("Kindly Review Orders of Customer'+customer+'.")</script>';
htmlPage = htmlPage + customer_list;
portlet.setHtml(htmlPage);
}
No comments:
Post a Comment