Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Get and assign a specific group's sys_id in Create Task activity

reym
Kilo Contributor

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!

1 ACCEPTED SOLUTION

Michael Fry1
Kilo Patron

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.


View solution in original post

4 REPLIES 4

Michael Fry1
Kilo Patron

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.


Thanks, Michael! In the end I resorted to hard-coding the sys_id instead as I can't get the GlideRecord method to work.


souren0071
Tera Expert

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:



  1. var group_gr = new GlideRecord('sys_user_group');  
  2. group_gr.addQuery('name','=','Staffing Vendor');   // value of the field needs to be used..."name" instead of "Name"
  3. group_gr.query();  
  4.   if(group_gr.next()){ //if or while should be used to iterate to the next value
  5. //task.assignment_group = current.assignment_group; <- Works fine but assigns the parent record's assignment group sys_id  
  6. task.assignment_group = group_gr.sys_id; // In spite of this assignment statement, the assignment group field is left blank  
  7. }


Please let me know if the issue has been resolved.



Regards,


Souren



PS: Your feedback (Like, Helpful or Correct) helps


reym
Kilo Contributor

souren007


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.