Flow designer -Based on location assignment group should be changed

Charutha R1
Tera Contributor

Hi @Ankur Bawiskar,

 

I have requirement where in when user's raise a request and a task will created for that request. (Task is created via flow designer) I need to populate assignment group of tasks based on drop-down variable 'city' in the catalog item. Based on the selection of the city, I need to map the Assignment group of the SC task. . 

For eg : If city is selected as banglore  it should assign to wp-banglore, if mumbai is selected,  it should assign to wp-mumbai and if delhi is selected the sc task assignment group should be wp-delhi.

 

Thanks

Charutha

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@Charutha R1 

while creating the task you can use the f(x) inline script and set the group field

just besides the group field you will see option to write script

Something like this

var city = fd_data.trigger.request_item.variables.city;

if(city == 'bangalore')
	return 'groupSysId1'; // group SysId

else if(city == 'mumbai')
	return 'groupSysId2'; // group sysId

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Charutha R1 

while creating the task you can use the f(x) inline script and set the group field

just besides the group field you will see option to write script

Something like this

var city = fd_data.trigger.request_item.variables.city;

if(city == 'bangalore')
	return 'groupSysId1'; // group SysId

else if(city == 'mumbai')
	return 'groupSysId2'; // group sysId

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

Hi @Ankur Bawiskar ,

 

If I have multiple records for location then what is your suggestion? There are more than 100 locations so it would be not possible for me to write all locations here.

 

Thanks,

Harsha

Amit Gujarathi
Giga Sage
Giga Sage

HI @Charutha R1 ,
I trust you are doing great.

  1. Create a new Catalog Item or modify the existing one to include a dropdown variable named 'city'. This variable will allow users to select the desired city.
  2. Define Assignment Groups in ServiceNow for each city you want to map. For example, create 'wp-banglore', 'wp-mumbai', and 'wp-delhi' Assignment Groups.
  3. Navigate to the Flow Designer in ServiceNow to create a new flow or modify the existing one for the task creation process.
  4. In the flow, locate the point where the task is being created after the request is submitted.
  5. Add a Script Action or a Function Action to include the logic for assigning the task to the appropriate Assignment Group based on the selected city.
  6. Write the following code inside the Script Action or Function Action to determine the Assignment Group dynamically based on the selected city:
var city = current.variables.city; // Fetch the selected city from the request
var assignmentGroup = '';

switch (city) {
  case 'banglore':
    assignmentGroup = 'wp-banglore';
    break;
  case 'mumbai':
    assignmentGroup = 'wp-mumbai';
    break;
  case 'delhi':
    assignmentGroup = 'wp-delhi';
    break;
  // Add more cases for other cities if necessary
  default:
    assignmentGroup = ''; // Handle the case when no city is selected or an invalid city is chosen
}

current.assignment_group = assignmentGroup; // Assign the determined Assignment Group to the task

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi