- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:28 AM
Can anyone share a business rule script on 'problem_task' table on how to find out if all the problem task are closed for the same problem.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:40 AM
Hello @Community Alums
Please find below snip -
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:39 AM
Hi Reaper,
Below is the script
var grProblem = new GlideRecord('problem_task');
grProblem.addQuery('problem', current.problem);
grProblem.query();
while(grProblem.next()){
//You can write the script what do you want to do will all the problem task records having same problem
}
If my answer helps then please mark it correct.
Thanks,
Utpal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 04:40 AM
Hello @Community Alums
Please find below snip -
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 04:46 AM
It's an OOB Business Rule, found it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-06-2023 06:36 AM - edited 11-06-2023 06:38 AM
Thank you @Utpal Dutta @Harsh_Deep for your replies
What I have written is quite a lengthy code compared to yours [Check below]
BR Script:
(function executeRule(current, previous /*null when async*/ ) {
var problemsysID = current.problem.sys_id;
var problemTaskNotClosed = new GlideAggregate('problem_task'); // To check how many problem task are available.
problemTaskNotClosed.addQuery('problem', current.problem);
problemTaskNotClosed.addAggregate('Count', 'problem');
problemTaskNotClosed.query();
while (problemTaskNotClosed.next()) {
var problemTaskNotClosedCount = problemTaskNotClosed.getAggregate('Count', 'problem');
}
gs.info("Reaper: problemTaskNotClosedCount : " + problemTaskNotClosedCount);
var problemTaskClosed = new GlideAggregate('problem_task'); // To check how many problem task are in closed state.
problemTaskClosed.addQuery('problem', current.problem);
problemTaskClosed.addQuery('state', '157')
problemTaskClosed.addAggregate('Count', 'problem');
problemTaskClosed.query();
while (problemTaskClosed.next()) {
var problemTaskClosedCount = problemTaskClosed.getAggregate('Count', 'problem');
}
gs.info("Reaper: problemTaskClosedCount : " + problemTaskClosedCount);
if (problemTaskNotClosedCount == problemTaskClosedCount) //check wehther all problem Task are in closed state.
gs.info("Reaper: All Problem Task are closeed" + current.problem.number);
else
gs.info("Reaper: Not all Problem Task are closed" + current.problem.number);
})(current, previous);
