Trigger Notification upon 50% duration elapsed for the Problem task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 02:02 AM
Can anyone explain how to trigger notification, when problem task elapsed 50% duration (Due Date – Assignment Date)/2? Can we do it with Scheduled job?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 03:06 AM
Create a new flow to trigger on the assignment date (you have the start) then. Add a wait condition to wait for a percentage duration on the due date and then the 'send notification' action to complete everything.
No need to script with all kinds of calculations you need to do.
Or, if you have SLA's running on the Problem tasks, you could utilize the OOB SLA workflow with its notifications on certain percentages.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2024 03:09 AM - edited 07-11-2024 03:16 AM
Yes, it can be done with Scheduled Job.
Add Script to Calculate 50% Duration and Trigger Notification in Scheduled Job
You can write your script with update in below Script.
var now = new GlideDateTime();
var problemTaskGR = new GlideRecord('problem_task');
problemTaskGR.addActiveQuery();
problemTaskGR.query();
while (problemTaskGR.next()) {
// Ensure due_date and assignment_date are set
if (problemTaskGR.due_date && problemTaskGR.assignment_date) {
var assignmentDate = problemTaskGR.assignment_date.getGlideObject();
var dueDate = problemTaskGR.due_date.getGlideObject();
// Calculate total duration in seconds
var totalDurationSeconds = (dueDate.getNumericValue() - assignmentDate.getNumericValue()) / 1000;
// Calculate 50% of the duration
var halfDurationSeconds = totalDurationSeconds / 2;
// Calculate the time when 50% duration elapses
var fiftyPercentElapsedTime = new GlideDateTime(assignmentDate);
fiftyPercentElapsedTime.addSeconds(halfDurationSeconds);
// Check if current time has passed the 50% elapsed time
if (now.after(fiftyPercentElapsedTime)) {
// Trigger Notification
gs.eventQueue('problem_task.50_percent_elapsed', problemTaskGR, problemTaskGR.assigned_to, gs.getUserID());
}
}
Create Notification
- When to send: Event is fired.
- Event name: problem_task.50_percent_elapsed.