Facing Problem with creation of Script Action In flow designer

saibhanuala
Tera Contributor

Hello everyone,

I’m working on a requirement where all newly created cases should be automatically assigned to employees in the relevant department, instead of assigning them manually.

To achieve this, I’ve implemented a Flow Designer solution:

  • Step 1: I used a Lookup Records action to fetch employees based on certain conditions (like matching department and lowest current load). This part is working correctly, and I’m getting the desired output.

  • Step 2: I now need to update the original case record (in another table) based on the employee retrieved in Step 1. Specifically, I want to set the assignedto field with the  sys_id of the selected employee and optionally update their.

I’m facing difficulty in creating a Script Action to perform this update logic inside Flow Designer. I’d appreciate any guidance or examples on how to correctly implement this using a Script step or alternative method.

1 ACCEPTED SOLUTION

Hi @saibhanuala ,

 

you can use the Look Up record action instead of (look up records action)

 

with department condition

 

where table name is employee table name and order by current_load (a to z) low to high

 

here is an example on the incident table

ChaitanyaILCR_0-1753117034977.png

ChaitanyaILCR_1-1753117152483.png

 

you can use the datapill and directly set the assigned on from the lookup record action

 

 

with look up records action you have to use for each action to access but with this you don't need extra step and your requirement suites it

 

hope this make sense

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

 

View solution in original post

5 REPLIES 5

GlideFather
Tera Patron

@saibhanuala 

If it is upon creation, don't you have there any action where do you populate short description or any other details, assignment group could be one more of it.

 

Or alternatively, you can use Assignment rules or a script field on the particular Case (eventually record producer).

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Pankaj kr
Kilo Sage

Hi @saibhanuala ,

 

This can be achieved directly without using script also. You can utilize the if employee in department found->true-> assign the employee sys_id from data pills to respective case-> end . This will be much smoother and easier. If i miss something, pls attach the snippet for better coverage of answer.

 

If this helped you, pls mark this as helpful and accepted.

 

Thanks,

Pankaj Kumar

Ankur Bawiskar
Tera Patron
Tera Patron

@saibhanuala 

You can use "Update Record" flow action and set the Assigned To as Output from Step 1

share screenshots.

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

saibhanuala
Tera Contributor

 

Use Case:
I have a table named ContactandSupport which stores reports raised by customers through my app. From the frontend, fields like Department and Subject are submitted by the user. There's also an AssignedTo field, which is a reference to another table called Employees.

 

Screenshot 2025-07-21 214608.png
Employees(Table)

saibhanuala_0-1753114897408.png
 

What I've Done So Far:

  1. I used the Look Up Records action in Flow Designer to fetch a set of employees belonging to the selected department.

  2. I am able to retrieve this list successfully using a Data Pill.

Issue I'm Facing:
Now that I have the list of employees, I want to update the AssignedTo field in the original report with one of these employees (preferably the one with the lowest current_load). However, I’m not sure how to take the output of the Lookup Records step and use it to update the record.



saibhanuala_1-1753115862116.png
Test