Configure a flag on problem records to inform problem manager when all PTASKs are closed.

Community Alums
Not applicable

How to configure a flag on problem list view to inform problem manager when all PTASKs are closed.

Could anyone suggest on how to proceed with this?

 

From what I understand, it should be like how when a incident is raised against a VIP user, in the list view you see a icon next to caller.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

@Sandeep Rajput Thank you!

ServiceNow already has an OOB Business Rule "Check related Problem Task closure" which checks for all PTask closure for an problem.

 

I have added below(Your) code to set the flag value in OOB business rule:

 

var problem = glideProblemTask.problem.getRefRecord();
problem.<name of your flag>='true'; //replace with your flag name
problem.update(); //Update is taking place on the problem record.

 

View solution in original post

9 REPLIES 9

Sandeep Rajput
Tera Patron
Tera Patron

@Community Alums By flag are you are referring to a custom column on the problem list. If yes then you can plan to create an onBefore update business rule on the problem_task table. Whenever, a problem tasks state changes to closed complete the script of the business rule will check the state of all the other problem tasks which are sharing a common parent. Accordingly the value of flag will be set to true if all the problem tasks are closed.

 

var glideProblemTask = new GlideRecord('problem_task');
glideProblemTask.addQuery('problem',current.getValue('problem'));
glideProblemTask.addQuery('sys_id','!=',current.getValue('sys_id'));
glideProblemTask.query();
var count=0;
var totalCount = glideProblemTask.getRowCount();
while(glideProblemTask.next()){
    if(glideProblemTask.getValue('state')!='157'){
        break;
    }
    else if(count==totalCount){
        var problem = glideProblemTask.problem.getRefRecord();
        problem.<name of your flag>='true';//replace with your flag name
        problem.update();
    }
    else{
        count++;
    }
}

Hope this helps.

Community Alums
Not applicable

Hi @Sandeep Rajput, Thanks for the response,

 

TBH, I don't know what it means to configure flag, but from what you have suggested and from other sources -

 

Does flagging means creating a checkbox variable on problem record and if all problem task are closed then making that checkbox as true(checked)?

@Community Alums Yes, your assumption is correct. There should be a checkbox field which will get checked via the script shared earlier when all the problem tasks are closed.

Community Alums
Not applicable

Hi @Sandeep Rajput 

could you please clarify this?

        var problem = glideProblemTask.problem.getRefRecord();
        problem.<name of your flag>='true';//replace with your flag name
        problem.update();

Why are we using getRefRecord() to set the flag value?

 

Can't we use dotwalking here - something like below:

Var gr = new GlideRecord('problem_task');
gr.get(' sys_id of PTask record ');
gr.problem.flag = 'true';
gr.update();

I have tried setting value through dotwalking but could not update it.