Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Problem

Anantha27
Mega Guru

In the problem when the priority is critical or high I need to create a PTASK automatically.

7 REPLIES 7

Pavankumar_1
Mega Patron

Hi @Anantha27 ,

create a new after business rule on problem table with the conditions priority as high or critical.

on advance section use below script.

 

 

(function executeRule(current, previous /*null when async*/ ) {
    var grPRTASK = new GlideRecord('problem_task');
    grPRTASK.initialize();
    grPRTASK.short_description = current.short_description;//problem short description
    grPRTASK.problem = current.sys_id; //problem sysid
    grPRTASK.insert();
})(current, previous);

 

 

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

NikhilKamlekar
Tera Expert

Hi @Anantha27 ,

If priority is Critical/High in Problem, You want to insert a new record in Problem Task:

You have 2 ways to approach this:

1) Flow Designer: If your condition Priority is Critical OR High then you can create a Problem Task with default value. Without any scripting. If you want some field values then configure as per requirement.

NikhilKamlekar_0-1729507290553.pngNikhilKamlekar_1-1729507328339.png

 


2) Through After BR on Insert OR update: You can use script for this to copy fields values of existing problem table to Problem task table.

NikhilKamlekar_2-1729507899077.pngNikhilKamlekar_3-1729507945230.pngNikhilKamlekar_4-1729507981559.pngNikhilKamlekar_5-1729508010123.png

 


Use either approach as per your requirement.
If my answer is helpful, then mark it as ''Helpful" and accept as a ''Solution"

Sai Krishna6147
Mega Guru

HI @Anantha27 
you can use the flow designer. The best way is to create business Rule to create PTASK automatically.