find sysid of existing group which is searched by name

Not applicable

plz tell where the problem is in this code. this is not assigning the task to found group 

 

var groupSysID ;
var groupName = current.variables.group_name;
var gr = new GlideRecord("sys_user_group");
gr.addQuery("name", "groupName");
gr.query();
if (gr.next()) {
groupSysID = gr.sys_id;
gs.addInfoMessage("found group" + gr.sys_id);
task.assignment_group = groupSysID;
}

1 ACCEPTED SOLUTION

Not applicable


var groupName = current.variables.group_name;
var gr = new GlideRecord("sys_user_group");
gr.addQuery("name", groupName);
gr.query();
if (gr.next()) {
var groupSysID = gr.sys_id;
gs.addInfoMessage("found group" + gr.sys_id);
task.assignment_group = groupSysID;
}

 

 

 

 

** i used groupName in double quotes ("") which was creating problems

 

View solution in original post

8 REPLIES 8

kristenankeny
Tera Guru

Where are you running this script?

Not applicable

in workflow RUN SCRIPT section/utilities

Ok, assuming that before this snippet of code, you've found the task via gliderecord and that glide record variable is called task, then add task.update().

Not applicable


var groupName = current.variables.group_name;
var gr = new GlideRecord("sys_user_group");
gr.addQuery("name", groupName);
gr.query();
if (gr.next()) {
var groupSysID = gr.sys_id;
gs.addInfoMessage("found group" + gr.sys_id);
task.assignment_group = groupSysID;
}

 

 

 

 

** i used groupName in double quotes ("") which was creating problems