- 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 04:03 AM
Expected output is to see the number of days in the list view under column days open
but currently its blank
FYI. the field is in table but not present in form.
i have configured it in the list
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 04:05 AM
Please find the updated code above
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 04:07 AM
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var datedif = gs.dateDiff(current.sys_created_on.getDisplayValue(), gs.nowDateTime());
var date1= datedif.split(" ");
gs.addInfoMessage("Days opened::"+date1[0]);
})(current, previous);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 04:37 AM
Ok then,
try a schedule job to run every day an update the field there.
Let me know the output
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-13-2017 04:55 AM