- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 05:26 PM
Hi everyone,
I know this is pretty basic but I've sent several hours already trying everything I know but can't get this to work.
Basically, I want to set the assignment_group field for a task record during record creation triggered by a Create Task activity. Using GlideRecord, I'm querying the sys_user_group table with the query Name = 'Staffing Vendor' then assigning the sys_id value into the task assignment group field but I can't for the life of me get it working.
My code is below:
var group_gr = new GlideRecord('sys_user_group');
group_gr.addQuery('Name','=','Staffing Vendor');
group_gr.query();
//task.assignment_group = current.assignment_group; <- Works fine but assigns the parent record's assignment group sys_id
task.assignment_group = group_gr.sys_id; // In spite of this assignment statement, the assignment group field is left blank
TIA!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 05:46 PM
Rey . . . I read this as just trying to set the assignment group to Staffing Vendor. If Yes, get the sys_id for that group, and then use:
task.assignment_group = 'sys_id of group';
replace sys_id of group with the sys_id of the group Staffing Vendor. No gliderecord needed.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 05:46 PM
Rey . . . I read this as just trying to set the assignment group to Staffing Vendor. If Yes, get the sys_id for that group, and then use:
task.assignment_group = 'sys_id of group';
replace sys_id of group with the sys_id of the group Staffing Vendor. No gliderecord needed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2017 04:26 PM
Thanks, Michael! In the end I resorted to hard-coding the sys_id instead as I can't get the GlideRecord method to work.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-13-2017 07:11 PM
Hi Rey,
As said you can directly assign the sys_id of the group. You can go to the group record named "Staffing Vendor" and right clicking on the header, you will get an option for Copy sys_id.
Or you can modify the code a little:
- var group_gr = new GlideRecord('sys_user_group');
- group_gr.addQuery('name','=','Staffing Vendor'); // value of the field needs to be used..."name" instead of "Name"
- group_gr.query();
- if(group_gr.next()){ //if or while should be used to iterate to the next value
- //task.assignment_group = current.assignment_group; <- Works fine but assigns the parent record's assignment group sys_id
- task.assignment_group = group_gr.sys_id; // In spite of this assignment statement, the assignment group field is left blank
- }
Please let me know if the issue has been resolved.
Regards,
Souren
PS: Your feedback (Like, Helpful or Correct) helps
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-15-2017 04:28 PM
Thanks for the help. I tried the solution changing "Name" to "name" but still can't get it to work. I resorted to just hard-coding the group's sys_id.