- 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-20-2017 05:10 AM
Hi Sreeja,
I checked it and it is working on my instance so please let me know what you're seeing that does not work and I will try to help.
Can you post your script?
Also:
1. Make sure you changed the field names to match yours.
2. Is your group field a simple reference field?
3. Is your Affected User field a list field, referencing to the User table?
4. There is no need for advanced ref qual in the Affected user field
Let me know
Harel
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2017 05:37 AM
Hi Harel,
This is the code I have used in OnChange Client script
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var grp = g_form.getValue('name_grp');
if(newValue=='') {
g_form.clearValue('group_mem');
}
var group = new GlideRecord('sys_user_grmember');
group.addQuery('group', grp);
group.query();
while(group.next()) {
var list = group.user;
var array = list.split(',');
for(var i=0; i<array.length;i++) {
var p = new GlideRecord('sys_user');
p.addQuery('sys_id', array[i]);
p.query();
p.query(getMeTheNames);
}
}
}
function getMeTheNames(p) {
var list = new Array();
while (p.next()) {
list.push(p.sys_id);
}
g_form.setValue('group_mem', list);
}
Here is the view of the item
And I have used Simple reference Qualifier in group field and haven't used advanced reference qualifier in group member field.
Please have a look and let me know if you find anything.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-20-2017 08:12 AM
My bad. Neglected to read list collector and read "list" only.
harel
- 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
05-29-2017 08:23 AM
Hi,
I'm trying to get this working for a table containing for then 600 records. The script workds fine but I'm facing an issue as the system is not going through all records of the table as the sluchbucket is limited to 100 records.
I can't change the property for the sluchbucket.
Does anyone have an idea how to sort this out ?
Many thanks in advance
Agathe