- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 02:14 AM - edited 05-25-2023 03:55 AM
Hi Ratnakar,
I've made the following changes as you suggested, it looks like it works but for this example ticket, that has been open for 24 hours, still evaluates true in debugging at 120 (5 days) of being open hmmm, it successfully evaluates as false for the 4, 24 and 72 statements.
Changes:
// Get length of time ticket has been open in days, hours, minutes, seconds
var diff2 = GlideDateTime.subtract(new GlideDateTime(gr.sys_created_on), new GlideDateTime());
var timeOpenMS = diff2.getDurationValue();
var timeOpen = new GlideDuration(timeOpenMS);
var timeOpenValue = timeOpen.getNumericValue();
// Incidents open for 5 days or longer, escalation is 0, priority is 1, 2, 3 or 4
// State is new or work in progress, escalation 0, priority is 1, 2, 3 or 4
if (timeOpenValue > 120 && data.table == 'incident' && gr.active == true && gr.priority == 1 || gr.priority == 2 || gr.priority == 3 || gr.priority == 4 && gr.incident_state == 1 || gr.incident_state == 2 && gr.escalation == 0 && gr.company == 'ad0459981b7c0c100375ca217e4bcbb0' && (gr.caller_id == gs.getUserID() || gs.hasRole("admin"))) {
data.showWidget = true;
data.showEscalate = true;
vEscalate = 0;
}
Edit:
Upon checking sys_log it looks like it's because the duration now shows as "The duration of this ticket is: 69367000" which is 0.8 days, so I don't think the conversion for timeOpenMS to timeOpenValue is working correctly.
I output the value of diff2 before any conversion and this is the value returned, I believe this is causing the issue?
1970-01-01 20:38:28
Edit 2:
Actually didn't notice some other syntax changes in your provided code, I've modified 120 to 5 days in milliseconds which is 432000000 and tested and it has worked now, thanks!