Need to create a new ptask when one ptask closed

PRAGHATIESH S
Tera Expert

In the problem record moves to RCA state, automatically one Ptask generated that is called "TEST". Once the TEST Ptask closed again one new Ptask should be auto generated. Can some one help me with the script and conditions on using business rule.

5 REPLIES 5

Jagadish Sanadi
Kilo Sage

Hi Praghatiesh,

 

Write on change client script.

In client script call script include to create PTASK.

 

Or

 

You can achieve with flow designer.

 

 

Please mark my reply helpful If I have answered you.

 

 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @PRAGHATIESH S 

 

In problem, the task are specific, if you want the same type of task as 2nd one, best option go low code. Create a Flow on problem table and 

Action

Create task

 

 

but here if there are 2- 3 task opened, ( may be different type) then you need to put a condition. Also in problem generally task creation done manually. 

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

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

Amit Verma
Kilo Patron
Kilo Patron

Hi @PRAGHATIESH S 

 

Better approach is to use a flow for this but if you want to proceed with a Business Rule, you can try as below :

 

Create an after update business rule on problem_task table with conditions like short_description contains Test or description contains Test and State is Closed ( Please modify the conditions as per your requirement) and make use of the below script to get the new Problem Task created.

 

AmitVerma_0-1706700545252.png

 

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

	// Add your code here
	gs.addInfoMessage(current.problem);
	var pTask = new GlideRecord('problem_task');
	pTask.initialize();
	pTask.short_description = 'Problem Task 2';
	pTask.problem_task_type = 'general';
	pTask.problem = current.problem;
	pTask.insert();

})(current, previous);

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.

Hi @PRAGHATIESH S 

 

If my response is able to help you, please mark the answer correct as well for others to reference. 

 

Thanks & Regards

Amit Verma


Please mark this response as correct and helpful if it assisted you with your question.