- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-18-2017 08:09 AM
Hi All,
I have a requirement to automate
1)assign role to users
2)assign users to a requested group
3)remove role from users
4)remove users from group.
through a catalog item.I am done with the flow.But if remove user from the group is selected from a particular group then only the user need to be populated who is within that group only.for that I need a dynamic reference qualifier.
for that we have some fields
1)Affected Users(List collector)
2)Required Group(reference)
The requirement is like depending on the group the user will be populated in Affected Users field.
can anyone please help me with the script.
Regards
Sreeja
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-23-2017 10:37 PM
Hi All,
Thanks for all of your responses.
Finally I got the resolution of my problem and here is the code that I have used in OnChange client script.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var grp = g_form.getValue('name_grp');
var usr;
var mem = 'group_mem';
var rightBucket= gel(mem+'_select_1');
var leftBucket = gel(mem+'_select_0');
rightBucket.options.length = '0';
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group',grp);
gr.query();
while(gr.next()){
usr=gr.user;
var selectedOptions = leftBucket.options;
var selectedIDs = new Array();
var index = 0;
for(var i = 0; i < selectedOptions.length; i++){
//alert(selectedOptions[i].value);
if(selectedOptions[i].value == usr){
//alert('1nsideif');
selectedIDs[index] = i;
index++;
}
}
moveSelectedOptions(selectedIDs, leftBucket, rightBucket, '--None--');
}
Regards
Sreeja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 12:16 AM
Hi Sreeja,
Try this code.
Create a script include and a function under it and write this code.
var grp = current.variables.variable_name; //Pass the variable name which selects Group
var answer;
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', grp);
gr.query();
while(gr.next()){
if (answer.length > 0) {
answer+ = (',' + gr.user.getValue("sys_id"));
}
else{
answer= gr.user.toString();
}
}
return 'sys_idIN' + answer;
In the Reference qualifier of the Affected user list in advanced one call this script include with current object.
Hope this helps you.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 03:32 AM
Hi Sreeja
Try using --- javascript:new findUser().grMember();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 03:42 AM
Hi Sneha,
If I use this only four users are coming in Affected user field even before selecting the group name.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 03:45 AM
Hi Sreeja,
I assume you need to add a check if group name is empty, in that case you need to return all the user records.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 03:51 AM
Hi Sneha,
My requirement is if any group is selected the group members will be populated in Affected users field. But I don't know why this is not working.
If anyone have any solution please help.
Regards,
Sreeja