Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

gs.getUser().isMember is not working in script include

GANESH23
Tera Contributor

Hi Folks,

Good Morning...

i have created one script include, which is using in advanced reference qualifier. i am check gs.getUser().isMember in script include but it is not working. please find my script below.

var filterUsersList = Class.create();
filterUsersList.prototype = Object.extendsObject(AbstractAjaxProcessor, {
filterUser: function() {
var grpList = '';
var custAccount = current.u_account;
if (gs.getUserID().isMemberOf('n') || gs.getUserID().hasRole('admin')) {
if (custAccount != '') {
gs.info("Logged in user"+gs.getUserID());
var users = new GlideRecord('sys_user');
var qc = users.addQuery('company', custAccount);
qc.addOrCondition('company', '54cffe00db66fb4092b6c9fb0b9619a3');
users.query();
while (users.next()) {
grpList += (',' + users.sys_id);

}
}
return 'sys_idIN' + grpList;
}

 

this script is i have check with client callable.

 

Thanks,

Mohan.

 

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron

Hi,

update as below

You had issue with the method; you were using incorrect one

gs.getUser().isMemberOf(Group Name') -> correct syntax

var filterUsersList = Class.create();
filterUsersList.prototype = Object.extendsObject(AbstractAjaxProcessor, {
filterUser: function() {
var grpList = '';
var custAccount = current.u_account;
if (gs.getUser().isMemberOf('n') || gs.hasRole('admin')) {
if (custAccount != '') {
gs.info("Logged in user"+gs.getUserID());
var users = new GlideRecord('sys_user');
var qc = users.addQuery('company', custAccount);
qc.addOrCondition('company', '54cffe00db66fb4092b6c9fb0b9619a3');
users.query();
while (users.next()) {
grpList += (',' + users.sys_id);

}
}
return 'sys_idIN' + grpList;
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

7 REPLIES 7

Ankur Bawiskar
Tera Patron

Hi,

update as below

You had issue with the method; you were using incorrect one

gs.getUser().isMemberOf(Group Name') -> correct syntax

var filterUsersList = Class.create();
filterUsersList.prototype = Object.extendsObject(AbstractAjaxProcessor, {
filterUser: function() {
var grpList = '';
var custAccount = current.u_account;
if (gs.getUser().isMemberOf('n') || gs.hasRole('admin')) {
if (custAccount != '') {
gs.info("Logged in user"+gs.getUserID());
var users = new GlideRecord('sys_user');
var qc = users.addQuery('company', custAccount);
qc.addOrCondition('company', '54cffe00db66fb4092b6c9fb0b9619a3');
users.query();
while (users.next()) {
grpList += (',' + users.sys_id);

}
}
return 'sys_idIN' + grpList;
}

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

 

tried above one also but luck. i have checked my logs as well. getting below msg.

find_real_file.png

 

TThanks,

Mohan

Hi,

gs.getUserID() -> should give you the user sys_id and not the user object

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 10x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi Ankur,

the above log message i got after changed to ur script(gs.getUser()).

what needs to do here on this

 

Thanks,