Get the number of problem tasks count present in problem table using GlideAggregate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2022 12:37 AM
Get the number of problem tasks count present in problem table, number should be populate in custom field(number of problem tasks) in problem after inserting new problem task Record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2022 12:40 AM
Hi,
Is that the total number of tasks, or the number of tasks for each problem?
If its for the number of tasks for that specific problem:
You need a business rule
Script:
(function executeRule(current, previous /*null when async*/) {
var probTask = new GlideAggregate('problem_task');
probTask.addQuery('problem', current.sys_id);
probTask.addAggregate('COUNT');
probTask.query();
if(probTask.next()){
probTask.next();
current.u_number_of_problem_tasks = probTask.getAggregate('COUNT');
}
})(current, previous);
Hope this helps.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2022 01:11 AM
Total no.of problem tasks present in each problem record

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-11-2022 01:27 AM
First script gives total number of problem tasks for that specific problem.
This second script gives total number of problem tasks for all records:
(function executeRule(current, previous /*null when async*/) {
var probTask = new GlideAggregate('problem_task');
probTask.addAggregate('COUNT');
probTask.query();
if(probTask.next()){
probTask.next();
current.u_number_of_problem_tasks = probTask.getAggregate('COUNT');
}
})(current, previous);
Hope this helps.
Please mark my answer as Correct/Helpful based on impact
Regards,
Dan H