Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-08-2025 05:13 AM
yes it's possible
you can use same script and enhance it further to iterate for all records
Create event and notification and trigger that event from script
var projectRec = new GlideRecord('pm_project');
projectRec.query();
while (projectRec.next()) {
var projectId = projectRec.sys_id;
var sevenDaysAgo = new GlideDateTime();
sevenDaysAgo.addDaysUTC(-7); // Get the date 7 days ago
// Check if "Percent Complete" was updated in the last 7 days
var percentCompleteUpdated = false;
var auditGR = new GlideRecord('sys_audit');
auditGR.addQuery('tablename', 'pm_project'); // Table name
auditGR.addQuery('fieldname', 'percent_complete'); // Field name
auditGR.addQuery('documentkey', projectId); // Project sys_id
auditGR.addQuery('sys_created_on', '>=', sevenDaysAgo); // Changes within last 7 days
auditGR.query();
if (auditGR.hasNext()) {
percentCompleteUpdated = true; // Found an update for "Percent Complete"
}
// Check if a status report was submitted in the last 7 days
var statusReportSubmitted = false;
var statusReportGR = new GlideRecord('project_status');
statusReportGR.addQuery('project', projectId); // Filter by current project
statusReportGR.addQuery('sys_created_on', '>=', sevenDaysAgo); // Submitted within last 7 days
statusReportGR.query();
if (statusReportGR.hasNext()) {
statusReportSubmitted = true; // Found a status report submission
}
// Trigger notification if both conditions are not met
if (!percentCompleteUpdated && !statusReportSubmitted) {
gs.eventQueue('eventName', projectRec, projectRec.assigned_to.email.toString());
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader