How to auto populate "Assign to" field present on the task record

sola2
Tera Contributor

Need to auto populate the "Assign to" field present on the task record to the person who approved the ticket. Do es anyone have any ideas on how to do it?

8 REPLIES 8

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @sola2 

 

What is use case ? and on which table you need this?

*************************************************************************************************************
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]

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

This is for the sc_task table. This is basically a HR request; approval is asked to the HR group and whoever approves it needs to be the "assign to" so that they can be responsible of fulfilling it.

Sandeep Rajput
Tera Patron
Tera Patron

@sola2 You would need to create a business rule as follows.

 

Screenshot 2024-02-03 at 12.04.56 AM.pngScreenshot 2024-02-03 at 12.03.14 AM.png

 

Here is the script

(function executeRule(current, previous /*null when async*/) {

	// Add your code here
	var taskRec = current.sysapproval.getRefRecord();
	taskRec.setValue('assigned_to',gs.getUserID());
	taskRec.update();

})(current, previous);

Hope this helps.

Is there any extra steps you have to do? I have it exactly as showed above but I do not have the "task type" field.

sola2_0-1707228930371.png