
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:25 AM
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.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 04:27 AM
@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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:42 AM
@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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 08:02 AM - edited 11-06-2023 08:03 AM
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)?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 08:57 AM
@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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-08-2023 01:46 AM
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.