Auto-Assignment Help!!

sanyalshubh
Tera Contributor

A user submits a request in Service Portal, and based on their role, the task needs to be automatically assigned to a specific user. For example, if the user has the "HR" role, the task should go to the HR team member.

3 ACCEPTED SOLUTIONS

Sandeep Rajput
Tera Patron
Tera Patron

@sanyalshubh There are multiple ways to achieve this implementation.

1. Business rule: create an onAfter insert business rule on the hr task table and check the user's role and assign the task to appropriate group

2. Flow: Create a flow which triggers on the task creation, check the requestor's role and assign's the task to appropriate group

3. Assignment rule: Check the requestor role in assignment role script and assign the task

4. Catalog OnSubmit client script: Check the user role in the catalog client script and assign the task.

 

Hope this helps.

View solution in original post

Ravi Gaurav
Giga Sage
Giga Sage

So I am assuming @sanyalshubh if its a record producer.. then you can write a RP script..
current.assigned_to='SYSID of Assignment Group"

or Using Business Rule :-
if (userRoles.indexOf('hr') > -1)

{

current.assigned_to = 'sys_id_of_HR_user';

 

}

you can use the above logic.. Let me know if that helped you..

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

View solution in original post

Hi @sanyalshubh 

 

It is either, the question is why role based ? Let say you created a record via catalog item, and you have 70 roles assigned, now on which basis system will pick the assignemnt.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

View solution in original post

10 REPLIES 10

Hi @sanyalshubh 

 

Understood, but this code will be good if you want to check/validate a security role, if more than one role needs to be validated or any specific role then the code needs to change.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************

Sandeep Rajput
Tera Patron
Tera Patron

@sanyalshubh There are multiple ways to achieve this implementation.

1. Business rule: create an onAfter insert business rule on the hr task table and check the user's role and assign the task to appropriate group

2. Flow: Create a flow which triggers on the task creation, check the requestor's role and assign's the task to appropriate group

3. Assignment rule: Check the requestor role in assignment role script and assign the task

4. Catalog OnSubmit client script: Check the user role in the catalog client script and assign the task.

 

Hope this helps.

Ravi Gaurav
Giga Sage
Giga Sage

So I am assuming @sanyalshubh if its a record producer.. then you can write a RP script..
current.assigned_to='SYSID of Assignment Group"

or Using Business Rule :-
if (userRoles.indexOf('hr') > -1)

{

current.assigned_to = 'sys_id_of_HR_user';

 

}

you can use the above logic.. Let me know if that helped you..

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/

Let me try @Ravi Gaurav 

Ankur Bawiskar
Tera Patron
Tera Patron

@sanyalshubh 

you can use HR assignment rules here and based on the HR service table set the Assigned to

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