- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-23-2016 12:38 PM
Man oh man.. how frustrating Date/Time calculations can be, am I right?
I built a new table for a customer who's looking to track their build book processes and needs to have four duration fields calculated by the system when he opens a record. I'm thinking if I can get one of them then I can easily get the rest so I've tried a couple of things with no success - see screen below for form layout.
Essentially the customer would like the duration between the system created time stamp (sys_created_on) and the current system date (the problem for me) and to have that duration be shown on the Total Time Open duration field (u_total_time_open).
Has anyone else gone though this kind of nightmare land and can lend a guy some assistance? Did i mention that I really hate date/time calculations.... lol
Bonus Question: I'm pretty sure I can do the other duration calculations since those fields are actually on the form and already being date stamped but will those duration calculations work if the Created field is a (date/time) and the other fields are date only OR do I need to make them date/time as well?
Thanks in advance.
Solved! Go to Solution.
- 6,049 Views
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2016 08:32 AM
Can you try
function onLoad() {
var strt = g_form.getValue('sys_created_on');
var ajax = new GlideAjax('AjaxDurCalcToday');
ajax.addParam('sysparm_name','durCalcToday');
ajax.addParam('sysparm_strt',strt);
ajax.getXMLWait();
var answer = ajax.getAnswer();
g_form.setValue('u_total_time_open', answer);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-28-2016 07:56 AM
I'm still nowhere on this. I've tried the glide ajax but it don't return anything and I can't use gs functions in Client scripts.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-18-2020 08:30 AM
I did this via before business rule:
The way I got it to work was this:
var start_date = new GlideDateTime(current.start);
var end_date = new GlideDateTime(current.end);
var calculation = new GlideDateTime.subtract(start_date, end_date);
current.u_outage_duration = calculation;