- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2017 11:01 AM
We have old incidents with business duration values 'zero'. So I wrote a background script to update values. In our business scenario we need to calculate the business duration as time between opened_at and resolved_at instead of closed_at. The problem is it gives same zero values if calculated between opened_at and resolved_at and gives correct values with closed_at.I don't understand this issue.?Anyone has any thoughts.
This is the background script
var result = 0, count = 0, opened, resolved;
var gr = new GlideRecord( 'incident' );
gr.addQuery("business_duration" , "CONTAINS", '1970-01-01 00:00:00' );
gr.addQuery('opened_at', '>=', '2015-04-02 00:00:00');
gr.addQuery('opened_at', '<=', '2015-05-31 23:59:59');
gr.query();
while(gr.next()) {
opened = gr.opened_at;
resolved= gr.resolved_at;
count++;
result = gs.calDateDiff(opened, resolved, false);
gs.print(gr.number + " " + result);
gr.business_duration=result;
gr.setWorkflow(false);
//gr.update();
}
gs.print("Total records : " + count);
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2017 01:23 PM
Harshini take a look at the resolved and closed dates for INC***572, Closed_at is more than 24hrs or 1day. That is why it is returning the value. Look at INC**571 it still returns 0 for both resolved and closed
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2017 01:08 PM
Harshini business duration should be atleast one day (more than 24hrs i'm guessing)
i tried to log result = gs.calDateDiff(opened, resolved, true); using true value in this statement.
For the field values to update it should be atleast more than 24hrs or 1 day. This is what i'm experiencing in my instance.
Attaching screenshot. It updated the first two records but not the third one.
Hope this helps
.
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2017 01:19 PM
Hi
Even I thought that and tried,but I get result for closed_at but not resolved_at.
See this output for resolved_at after making it true
*** Script: INC0010571 0
*** Script: 2015-04-02 18:10:12
*** Script: 2015-04-02 18:18:45
*** Script: INC0010572 0
*** Script: 2015-04-02 18:11:44
*** Script: 2015-04-02 19:41:18
*** Script: INC0010574 0
*** Script: 2015-04-02 18:28:19
*** Script: 2015-04-02 19:42:35
*** Script: INC0010587 0
*** Script: 2015-04-02 21:24:21
*** Script: 2015-04-02 21:32:43
*** Script: INC0010589 0
*** Script: 2015-04-02 21:49:16
*** Script: 2015-04-02 22:27:46
*** Script: INC0010596 0
*** Script: 2015-04-02 22:56:35
*** Script: 2015-04-02 23:00:12
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2017 01:20 PM
And the same code for closed_at:
*** Script: INC0010571 0
*** Script: 2015-04-02 18:10:12
*** Script: 2015-04-02 18:18:45
*** Script: INC0010572 32400
*** Script: 2015-04-02 18:11:44
*** Script: 2015-04-06 05:00:06
*** Script: INC0010574 32400
*** Script: 2015-04-02 18:28:19
*** Script: 2015-04-06 05:00:08
*** Script: INC0010587 32400
*** Script: 2015-04-02 21:24:21
*** Script: 2015-04-06 05:00:07
*** Script: INC0010589 0
*** Script: 2015-04-02 21:49:16
*** Script: 2015-04-02 22:27:46
*** Script: INC0010596 32400
*** Script: 2015-04-02 22:56:35
*** Script: 2015-04-06 05:00:08
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2017 01:23 PM
Harshini take a look at the resolved and closed dates for INC***572, Closed_at is more than 24hrs or 1day. That is why it is returning the value. Look at INC**571 it still returns 0 for both resolved and closed
Please mark my response as correct and helpful if it helped solved your question.
-Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-06-2017 01:33 PM
I get your point.Now,I have to find a way to calculate the values even if it is not more than 24hrs.