Auto-create Problem Task (PTASK) for P1 & P2 Problems – Best Practice Configuration

nameisnani
Mega Sage
Hi Community,
 
We have a requirement to automatically create a Problem Task (PTASK) when a Problem record is created for P1 or P2, and I’m looking for validation / best‑practice confirmation.
 

Business Requirement

  1. When a Problem record is created
  2. If Problem Priority = P1 or P2
  3. System should automatically create a Problem Task (PTASK)
  4. Assignment Group & Assigned To on the PTASK should be inherited from the resolver group of the related P1 / P2 Incident
  5. No PTASK should be created for P3 / P4 Problems
  6. Duplicate PTASKs should be avoided

 

can any one please provide the configuration steps 

 

Ehab Pilloor

 

@Ehab Pilloor  .could you please help me here with steps 

 
 
 
   
 
 
 
 
 
 
 
 
3 REPLIES 3

Tanushree Maiti
Giga Patron

Hi @nameisnani 

 

Create an After insert, update BR for it.

 

  • Table: Problem (problem)
  • When: After
  • Insert: Checked
  • Update: Unchecked
  • Condition: Priority is one of P1 or P2

 

 

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

   

     var relatedIncident = new GlideRecord('incident');

    if (relatedIncident.get(current.rfc)) {

       

        var assignmentGroup = relatedIncident.assignment_group;

        var assignedTo = relatedIncident.assigned_to;

       

        var pTaskGr = new GlideRecord('problem_task');

        pTaskGr.addQuery('problem', current.sys_id);

        pTaskGr.addQuery('assignment_group', assignmentGroup);

        pTaskGr.addQuery('assigned_to', assignedTo);

        pTaskGr.query();

       

        if (!pTaskGr.hasNext()) {

            var newTask = new GlideRecord('problem_task');

            newTask.initialize();

            newTask.problem = current.sys_id;

            newTask.assignment_group = assignmentGroup;

            newTask.assigned_to = assignedTo;

            newTask.short_description = 'Investigate P1/P2 Incident root cause'; // Customize as needed

            newTask.insert();

        }

    }

 

})(current, previous);

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

Ehab Pilloor
Mega Sage

Hi @nameisnani,

 

You can use Flow Designer to create PTask for creation of P1 or P2 Problem or an after insert BR as Tanushree mentioned.

 

Regards,

Ehab Pilloor

 

@nameisnani,

 

If you use Flow Designer,

 

Set record based trigger, only for record created. Condition will be Priority is P1 or Priority is P2. Use Create record action, table = PTask. 

Autofill values for PTask fields using data pills from Problem record.

Set the correct State.

 

Regards,

Ehab Pilloor