- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2017 03:09 AM
HI Experts i am trying to write code to calculate no of days a ticket has been opened based on only sys_created_on .
Below is the code that i tweaked little bit but its not working
below is script include:
var CalculateDuration = Class.create();
CalculateDuration.prototype = {
calculate_duration : function(start) {
var duration.seconds = {};
duration.days = parseInt(duration.seconds * 100 / 86400,10)/100;
return duration;
}
};
Buisness rule where i am calling
(function executeRule(current, previous /*null when async*/) {
var start = current.sys_created_on.getDisplayValue();
var td = new CalculateDuration();
var duration = td.calculate_duration(start);
current.u_days_open = duration.days;
})(current, previous);
Any leads where i am going wrong
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2017 07:21 AM
Strange Occurence - below code is changing only 5 records , rest are not updated .
this field is a duration type field
hope that is not going wrong
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2017 07:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-15-2017 11:40 PM
Hey Deep,
I made the field as String in my form. And that works fantastic.
Regards,
Divya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 12:15 AM
created a scheduled job
below code worked for me
var sc = new GlideRecord('u_legal_point_request');
sc.query();
while(sc.next()){
var dat = new GlideDateTime();
var datedif = gs.dateDiff(sc.sys_created_on,dat);
sc.u_days_open = datedif;
sc.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 12:22 AM
Hey Deep,
Great work!!! Choice of field can be as per your choice
post me your feedback
Please Hit ✅Correct, âÂ��Helpful, or ��Like depending on the impact of the response
Have a lovely day ahead
Regards,
Divya Mishra

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-16-2017 12:11 AM
I thinks, Since Duration extends Date/time so setting value of days only will not work correctly. You can use time 00 with your days value as suggested by @Lakshminarayana Yamarthy .
You can use string instead for days only value.