Scheduled script with GlideAggregate
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2024 08:27 AM
Hello All,
I need to modify this scheduled script notification - according to best practice it should contain GlideAggregate instead of getRowCount (line 5). The script should send notification to Portfolio Manager for inactive project managers. The script with getRowCount is working fine but after modification it has stopped and I am not sure what I did wrong.
The script with getRowCount on line 5 is:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 04:35 AM
Hi @Martyna, I noticed that my script doesn't have the query variable declared. Can you add the query variable and try?
var query = "project_manager.active=false^stateNOT IN3,4,7^primary_portfolio.portfolio_managerISNOTEMPTY^project_managerISNOTEMPTY";
var gaProject = new GlideAggregate('pm_project');
gaProject.addEncodedQuery(query);
gaProject.addAggregate('COUNT');
gaProject.query();
var rowCount = 0;
if (gaProject.next()) {
rowCount = gaProject.getAggregate('COUNT');
}
var grProject = new GlideRecord('pm_project');
grProject.addEncodedQuery(query);
grProject.query();
while (grProject.next()) {
projectManagerList.push(grProject.project_manager.trim());
portfolioManagerList.push(grProject.primary_portfolio.portfolio_manager.trim());
gs.print(grProject.project_manager + '');
gs.print(grProject.primary_portfolio.portfolio_manager + '');
}
Regards,
Sunil
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-07-2024 04:46 AM
I have already added declared query variable and it still does not work 😞