How to assign assignment group as per location

RunaliP
Tera Contributor

I am working on catlog item, my requirement is when line manager approve a request then it should be assign to that particular team as per the location.

 

In UI there is location field if requestor will select any location .

so according to that location it should be assign to that particular location team.

 

For this i have to create workflow. I m trying it with Run script 

please provide solution on it. 

 

Thank You

5 REPLIES 5

Ankur Bawiskar
Tera Patron
Tera Patron

@RunaliP 

your script is wrong.

please share your script here

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@RunaliP 

I believe you have created custom location field on sys_user_group table

Based on that you want to set the catalog task group?

If yes then this advanced script will help in Catalog Task activity in workflow

var loc = current.variables.current_location; // give correct variable name here
var groupRec = new GlideRecord('sys_user_group');
groupRec.addQuery('u_location', loc); // give here the custom location field name
groupRec.query();
if (groupRec.next()) {
    task.assignment_group = groupRec.getUniqueValue();
}

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@RunaliP 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ashish Parab
Mega Sage

Hello @RunaliP , 

 

Why you have created workflow? Instead of creating a workflow, consider using a Flow in Flow Designer. You can utilize If-Else conditions to evaluate the location selected in the catalog. Based on the selected location, use the Update Record action to assign the appropriate Assignment Group dynamically.

Please mark this as "correct" and "helpful" if you feel this answer helped you in anyway.

 

Thanks and Regards,

Ashish