Skip to content

Instantly share code, notes, and snippets.

@wave-inguane
Last active Aug 31, 2021
Embed
What would you like to do?
UtilScriptInclude
/***************************************************************************************************************************************
*
***************************************************************************************************************************************/
/***************************************************************************************************************************************
* Script Include for reference qualifiers
***************************************************************************************************************************************/
Usage: javascript: new global.SMARTFilterListsV2().filterShowInternalGroups();
javascript: new global.SMARTFilterListsV2().filterShowOtherInternalGroups(current.variables.select_team_member_to_modify);
javascript: new global.SMARTFilterListsV2().filterShowMyGroups(current.variables.select_team_member_to_modify);
var SMARTFilterListsV2 = Class.create();
SMARTFilterListsV2.prototype = {
initialize: function() {
},
filterShowInternalGroups: function() {
var groups = new GlideRecord('sys_user_group');
groups.addActiveQuery();
//groups.addEncodedQuery("type!=NULL^type=c822543f1b966c986a2e4196bc4bcbf5");
groups.query();
var groupList;
while(groups.next()) {
groupList += ","+groups.sys_id;
}
return 'sys_idIN'+groupList;
},
filterShowInternalUers: function() {
var grUser = new GlideRecord('sys_user');
grUser.addActiveQuery();
//grUser.addQuery("u_type","Internal");
grUser.query();
var userList;
while(grUser.next()) {
userList += ","+grUser.sys_id;
}
return 'sys_idIN'+userList;
},
//****************************************************************************************************************
// USAGE
// javascript: new x_smart.SMARTFilterLists().filterShowMyGroups(current.variables.select_team_member_to_modify);
//****************************************************************************************************************
filterShowMyGroups: function(userId) {
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery("user",userId);
grMember.query();
var groupList;
while(grMember.next()) {
groupList += ","+grMember.group;
}
return 'sys_idIN'+groupList;
},
filterShowOtherInternalGroups: function(userId) {
//gs.info("IDD = "+userId);
var grMember = new GlideRecord('sys_user_grmember');
grMember.addQuery("user",userId);
grMember.query();
var currentGroups;
while(grMember.next()) {
currentGroups += ","+grMember.group;
}
var groups = new GlideRecord('sys_user_group');
groups.addActiveQuery();
//groups.addEncodedQuery("type!=NULL^type=c822543f1b966c986a2e4196bc4bcbf5");
//groups.addQuery("sys_id","NOT IN",currentGroups);
groups.query();
var groupList;
while(groups.next()) {
groupList += ","+groups.sys_id;
}
return 'sys_idIN'+groupList;
},
type: 'SMARTFilterListsV2'
};
/***************************************************************************************************************************************
*
***************************************************************************************************************************************/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment