To add a members in a group table via record producer

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2015 05:44 AM
Requirement is to add a members in a group table via record producer
I have made three variables one as a reference variable to sys_user_group table
second, drop down with value add and remove
third, list collector on table sys_user
On the basis of group selection, and add value in drop down variable,
in the slush bucket, Users who are member of selected group should be pre-selected in right side of slush bucket and on left side all remaining active users..
On the basis of group selection, and remove value in drop down variable, only members of selected variables should be visible on left side of bucket.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2015 06:47 AM
Hello Aanchal,
Are you facing any issue or do you want to know how to add the selected user(s) added/removed to/from a group?
If you want to know about the process how to add/remove,
1. Fetch the data from record producer.
2. Run a script (in business rule or in workflow script or else) to add/remove the user(s).
Script to add user to a group :
var gr_add = new GlideRecord('sys_user_grmember');
gr_add.initialize();
gr_add.group = "sys_id of the group"
gr_add.user = "sys_id of the user";
gr_add.insert();
Hope, you would be able to write the script for removal of a user too.
If you have any issue, please reply with the issue description.
Thanks,
Subhankar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2015 07:02 AM
Hi Aanchal,
If I understand your question correctly, I think you are looking to move the list collector options based on some logic you have mentioned above.
Please refer the below thread and adjust your solution accordingly.
http://www.servicenowguru.com/scripting/client-scripts-scripting/move-list-collector-options/
I hope this helps

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2015 01:55 AM
Hi Pradeep,
Thanks, This is helpful link in case of add option.
And in case of remove option,
Basically i want to set default filter as "only those users shall display in the slush bucket ,who are part of the selected group". So i wrote a below catalog client script.But it's not working. Can you please look once?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var a = g_form.getValue('group');//name of the group variable
alert(a);
function setMyFilter() {
PleaseSelectg_filter.reset();
var answer = '';
var usr = '';
var gr = new GlideRecord('sys_user_grmember');
gr.addQuery('group' , 'a');
gr.query();
while(gr.next())
{
usr = gr.user.getDisplayValue();
return usr;
}
answer += 'user='+usr;
PleaseSelectg_filter.setQuery(answer);
PleaseSelectacRequest(null);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-14-2015 02:13 AM
Hello Aanchal,
You can do it by configuring a script include and call it from the variable's Reference Qual as javascript : FUNCTIONNAME();
I hope you want this configuration only when user selects the remove option.
Hence, configure accordingly.
Thanks,
Subhankar