Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

Gtt Reqested Item varible onto Catalog tasks in workflow

Shree Nag
Tera Expert

Hello,

Thank you in advance for looking into the post and helping.

I'm trying to get requested item's Assignment group to catalog task assignment group in the workflow activity.

This code is present in the script section of the workflow.

I'm unable to get the selected assignment group on Req item to catalog task's assignment grup

 

I have attached a pic of the workflow activity

// Set Assignment Group
var ritm = current.request_item.getRefRecord();
if (!gs.nil(current.variables.assignment_group)) {
    task.assignment_group = ritm.assignment_group;
} else {
   // task.assignment_group = "e662aaa847b07190f726ba67436d43de"; // sys_id of Service Desk group recommended
}

// Set Assigned To
if (!gs.nil(current.variables.manager)) {
   task.assigned_to =  ritm.manager;
}
 
 
Please help.
 
-Thanks
2 REPLIES 2

Brad Bowman
Mega Patron

The workflow is likely running on the sc_req_item table, 'current' refers to the the RITM.  Use current.field_name to access fields on the sc_req_item table, and current.variables.variable_name to access Catalog Item variables.

 

So your script would look more like this, depending on knowing the distinction between fields and variables, using the correct names for both in your instance, and logic - setting the value to that of a field after checking that a variable with the same name is not empty doesn't make any sense:

// Set Assignment Group
if (!gs.nil(current.variables.assignment_group)) {
    task.assignment_group = current.assignment_group;
} else {
   // task.assignment_group = "e662aaa847b07190f726ba67436d43de"; // sys_id of Service Desk group recommended
}

// Set Assigned To
if (!gs.nil(current.variables.manager)) {
   task.assigned_to = current.manager; //not an out of box field, check the name
}

 

Tanushree Maiti
Tera Sage

Hi @Shree Nag 

 

To map the Requested Item's (RITM) Assignment Group to a Catalog Task in Flow Designer,
use the "Create Catalog Task" action and use the Data Pill Picker
to select Trigger -> Requested Item Record -> Assignment Group.

This ensures the task inherits the group directly from the RITM, dynamically populating it without scripting.

 

Refer : how to navigate in flow - check this.

https://www.youtube.com/watch?v=GljJd7hijyw&t=802s

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:
Ever wondered how to use flow designer for a ServiceNow Service Catalog? In this video we look at what Flow Designer is and how to create a new flow for a Catalog Item. This includes adding an approval activity, a catalogue task with variables, an if statement and the illustrious..how to add ...