This topic contains 3 replies, has 0 voices, and was last updated by TheUsualSuspect 6 years, 4 months ago.
-
AuthorPosts
-
June 20, 2018 at 1:12 pm #17977
vkwanengageHello NS community,
I was wondering, is there a way to get all users who have “Administrative Role” via SuiteScript? I want to be able to get all these users so i can alert them of some actions via email.
Thanks.
This is a cached copy. Click here to see the original post. -
June 21, 2018 at 9:35 am #17978
dominicbDepending on exactly what you’re trying to alert, it may be easier to just use a saved search?
If not, SS2.0 (straight out of David Smith’s search export Chrome extension):
Code:
var employeeSearchObj = search.create({
type: “employee”,
filters:
[
[“role”,”anyof”,”3″]
],
columns:
[
search.createColumn({
name: “entityid”,
sort: search.Sort.ASC,
label: “Name”
}),
search.createColumn({name: “email”, label: “Email”}),
search.createColumn({name: “title”, label: “Job Title”})
]
});
var searchResultCount = employeeSearchObj.runPaged().count;
log.debug(“employeeSearchObj result count”,searchResultCount);
employeeSearchObj.run().each(function(result){
// .run().each has a limit of 4,000 results
return true;
}); -
June 21, 2018 at 11:59 am #17979
vkwanengageThanks dominicb
-
June 28, 2018 at 2:43 pm #17980
TheUsualSuspectAdding to dominicb answer somewhat. You can create a dynamic Group in NetSuite for employees with administrator roles and load the record in script using the ‘entitygroup’ record type. The only real benefit over a direct saved search is some easier management / maintenance for non-technical users in case additional criteria or special cases develop.
Code:
getEmailRecipients: function(entityGroup) {
log.debug({ ‘title’: ‘Entity Error Group Id’, ‘details’: entityGroup });
if (entityGroup) {
var entityGroupRec = record.load({ type: ‘entitygroup’, id: entityGroup });
var memberCount = entityGroupRec.getLineCount(‘groupmembers’);
var emailList = [];
for (var i = 0; i <= memberCount; i++) {
var email = entityGroupRec.getSublistValue({ sublistId: 'groupmembers', fieldId: 'memberemail', line: i });
if (email) { emailList.push(email); }
}
}
log.debug({ 'title': 'List of recipients', 'details': JSON.stringify(emailList) });
return emailList.toString();
} -
AuthorPosts
You must be logged in to reply to this topic.