Assign Catalog Task to assignment group manager

Rick Mann
Tera Expert

I am creating a new catalog task where the assignment group will be Database Administration and the "assigned to" should be the group manager of the assignment group. Is there a way dynamically make the group manager the assigned IT Rep for the task?

I saw another post that discussed something similar: Auto fill Assignment group and/or Assigned to in Catalog Task based on variables

I also tried adding the following line to the advanced script section of the catalog task: task.assigned_to = sys_user_group.manager;

Any help is appreciated.

Rick

5 REPLIES 5

Jace Benson
Mega Sage

You should be able to do something like that. I have more complicated automatic assignments and have found that calling out a custom business rule makes my life easier.

To make the task know what sys_user_group you want you need to tell it that. People can belong to multiple groups. If you are going to set this on the individual tasks, you could just write it in a query like so;



var usergroup = new Gliderecord('sys_user_group');
//you could somehow dynamically get this information
var somevariable = "Database Administration";
usergroup.addQuery('name','=',somevariable);
usergroup.query();
while (usergroup.next())
{//so long as there isn't two groups with the same name you should get the expected result
task.assigned_to = usergroup.manager;
}


Using a business rule would make this less something like


function assigntogroupmanager(group){
var usergroup = new Gliderecord('sys_user_group');
usergroup.addQuery('name','=',group);
usergroup.query();
while (usergroup.next())
{
//so long as there isn't two groups with the same name you should get the expected result
return usergroup.manager;
}
}

Then use the business rule in the script;

task.assigned_to = assigntogroupmanager("Database Administration");


Thanks for the reply. I'm just now getting an opportunity to look at this. I tried adding the script below to the catalog task that I'm generating, but task is not being assigned to the group manager. Also, if I went the BR route... Would I make the BR global or on the sc_task table?

var usergroup = new Gliderecord('sys_user_group');
var groupname = "Database Administration";
usergroup.addQuery('name','=',groupname);
usergroup.query();
while (usergroup.next())
{
task.assigned_to = usergroup.manager;
}

Thanks again for the help!


I think it would be a safer bet to use the sys_id of the record rather than the name of the group. Try using this.



var grp = '8a5055c9c61122780043563ef53438e3'; //enter the sys_id of the Database Administration group
var usergroup = new GlideRecord('sys_user_group');
usergroup.addQuery('sys_id', grp);
usergroup.query();
while(usergroup.next()){
var mgr = usergroup.manager.getDisplayValue();
task.assigned_to = mgr;
}


I ran this on my instance and it worked.


You could also set both the assignment group and assigned to in an advanced script during the catalog task creation from the workflow.



task.assignment_group.setDisplayValue('Database Administration');
task.assigned_to = task.assignment_group.manager;