Get users from specific assignment groups (Reference to user table)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 09:21 AM
Hi All,
There is a field called Requested for which references to sys_user table. This field should only show the users who are part of the Admin, Software and Hardware assignment groups.
Can anyone guide me on this.
Thanks in Advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 09:39 AM
Hi @Nagashree5 ,
Write a client script [ onLaod ] on that table for check the logged in user group membership.
function onLoad() {
var usr = g_user.getUserID();
// set the correct grouop name and add more group using OR || operator
if (!usr.isMemberOf('<group>')){
g_form.setVisible("requested_for",false);
}
or you can write the same logic using the UI Policy
-Thanks,
AshishKM
Please mark this response as correct and helpful if it helps you can mark more that one reply as accepted solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-05-2024 10:21 AM
Hi @Nagashree5 ,
You need to use Advanced Reference Qualifier to show users which are part of of the Admin, Software and Hardware groups
Create Script Include -
var getUsers = Class.create();
getUsers.prototype = {
initialize: function() {
},
getUserSysIds:function(){
var usersList =[];
var gr = new GlideRecord('sys_user_grmember');
var cond = gr.addQuery('group','8a4dde73c6112278017a6a4baf547aa7');// sysId of Software Group
cond.addOrCondition('group','8a5055c9c61122780043563ef53438e3');//sysId of Hardware Group
// add more condition for admin cond.addOrCondition('group','admin group sys_id');
gr.query();
while(gr.next()){
usersList.push(gr.user.toString());
}
return 'sys_idIN' + usersList;
},
type: 'getUsers'
};
Once this is done Right click on 'Requested for' field and click on Configure Dictionary -> Click on 'Advanced View' Related Link and Select 'Use reference qualifier' as 'Advanced ' and Paste the below Script
javascript: new getUsers().getUserSysIds();
Now the Requested for will only show users which are part of mentioned groups
If my reply helped with your issue please mark helpful 👍 and correct ✔️ if your issue is resolved.
By doing so you help other community members find resolved questions which may relate to an issue they're having
Thanks,
Astik