- 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 01:35 AM
Hi Sreeja,
Please find the modified code below. I believe this should work for the List collector type variable also.
var answer= '';
var grp= current.variables.variable_name;
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group', grp);
gr.query();
while(gr.next()) {
if (answer.length > 0) {
answer+= (',' + gr.user.sys_id).toString();
}
else {
answer= gr.user.sys_id.toString();
}
}
return 'sys_idIN' + answer;
Find the snapshot below:
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-19-2017 03:24 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2017 02:01 AM
Hi Sreeja,
The code of Script Include which I have provided in my last response works perfectly fine for the 'Reference' type variable. I have cross checked in my personal instance. You need to call the script include in the advance reference qualifier as javascript:findUser();
However, in reference qualifier in List Collector type variable doesn't work correctly. You can refer Ankur's response in this thread Advanced reference qualifier on a variable in order guide .
For more information on using Reference qualifier in List Collector type variable you can also refer this blog: Filtering on the List Collector or SlushBucket variable in Helsinki .
As of now, if the requirement remains same, i.e., to show list of Users based on selected Group, I would suggest you to change the variable type from 'List Collector' to 'Reference'. However, I will get back to you later if I find any solution for List Collector type variables.
I hope this helps.Please mark correct/helpful based on impact
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2017 02:06 AM
Thank you so much Amlan.
But its not possible for me to change the type of this variable since multiple user can be there. please get back to me if you find anything.
Thanks Again.
Regards,
Sreeja
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-20-2017 11:03 PM
Hi Sreeja,
I have debug your issue and found the issue more interesting. Hence initiated a new thread regarding the same. Please track this thread over here Reference Qualifier Issue in List Collector Type Variable and hope you will get your answer over there.
If you want, you can also mark corresponding answer correct, close this thread and track the thread mentioned in this response.
I hope this helps.Please mark correct/helpful based on impact