Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

problem should not resolve if associated ptask is open

ashimghosh1
Mega Contributor

I want to create business rule like if the problem associated Ptask is not resolved then problem should not be resolved.

5 REPLIES 5

Aanchal Agarwa1
Tera Expert

Hi @ashimghosh1 ,

As suggested it can be achieved via before business rule 

 

Name : Restrict Problem Resolution with Open Tasks

Table:  Problem [problem]

Advanced    :    Checked

When  :Before

Update  :  Checked

 

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

    var taskGR = new GlideRecord('problem_task');

    taskGR.addQuery('problem', current.getUniqueValue()); 

    taskGR.addActiveQuery(); 

    taskGR.setLimit(1 ); 

    taskGR.query();

    if (taskGR.next()) {

        gs.addErrorMessage('Cannot resolve this Problem because one or more associated Problem Tasks are still open.');

        current.setAbortAction(true); 

    }

})(current, previous);

 

For a low code alternative approach 

  1. Go to Flow Designer → Create New Flow
  2. Trigger = Record Updated → Table = problem → Condition = State changes to Resolved
  3. Action = Look up Records on problem_task where:
    • problem = trigger record
    • state != resolved (i.e. open or in progress tasks exist)
  4. If results found → Use Update Record action to revert problem state back to In Progress

 

Thanks
Aanchal