Days open count
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 06:23 AM
Hi,
I am trying to add a read only field on the incident form which counts how many days a ticket has been open for. I have done something similar at a previous company to count the amount of times a ticket is reassigned and then fire an email to management if the ticket has "bounced" more than 4 times. I have got this working at my current company but I am struggling to see how I now turn it into a days opened count.
Any ideas?
Kind Regards

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 07:03 AM
Hi Steve,
My thoughts here are you can write the schedule job script which will run daily at midnight with the condition to check "if the ticket is created before 4 days and active is true and state is open" i.e Script : "active=true^state=1^sys_created_onRELATIVELT@dayofweek@ago@4" and update the count in the field created on the form.
Fire the event to trigger notification If the count is 4 on the form.
Also please go through the "GlideSystem Date and Time Functions" on wiki which will give you some idea
http://wiki.servicenow.com/index.php?title=GlideSystem_Date_and_Time_Functions
Please let me know if you have any questions.
Looking for others thoughts as well
Thanks,
Pradeep Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 08:02 AM
I agree with Pradeep on this, however if you are looking for the days value to be updated everyday,
say on 1st day value =1
2nd day value =2... you may consider decreasing the interval of the job to everyday midnight, but that still wont eliminate the problem.
Sample Use Case , if the ticket is created GMT+5.30 today where job was run already at midnight, the next turn for the job would be after 24 hours again, by that time ticket will complete more than 1 day(probably 1 day 18.5 hours).You may consider decreasing the job interval again for 1 half day which will drive you towards accuracy, but that does not eliminate the problem completely.
You may consider calculated fields for this purpose,
if you want to trigger email after 4 days, you can consider writing insert business rule and scheduleonce script
Call a ServiceNow script asynchronously with ScheduleOnce API-John James Andersen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2014 11:34 AM
you can create a glide duration field that is calculated with a calculation of "current.calendar_duration = gs.dateDiff(current.sys_created_on.getDisplayValue(),gs.nowDateTime(),false);" to show the time the ticket has been opened.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-16-2014 07:46 AM
This sounds like it would be better suited as an SLA/OLA to me rather than as a field and email combo. Setting up an SLA will handle the duration calculations for you and with an SLA workflow will handle the notifications at preset intervals.
Also, if the only purpose of the field is to trigger the email (you don't need to report on it), then you could just create a workflow with a timer. This would have less of an impact on the system than recalculating a field on every record every time it is queried.
The question I would ask in this situation, do I need to know EXACTLY how long something has been opened, or am I more concerned with certain predetermined moments (1-2 days, less than a week, less than 2 weeks, etc). Needing an exact count at every moment will be best suited to a calculated field. If you are more interested in when an incident crosses certain boundaries, workflows and SLA's would be your better choice. (The workflow with a timer could also recalculate a field at predetermined intervals as well).