I want to find the difference between the two date time fields and need to update in other duration field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 02:45 AM
I want to find the difference between the two date time fields and need to update in other duration field.
Log in Time and Logoff time are Date/ Time fields and Total Log time is duration field.
I have written server side script for this to work calling a glide ajax call. But it is not calculating the difference.
Client script:
Script include is:
Please help me to resolve it.
Thanks in Advance.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 04:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 04:57 AM
Yes..
Client script:
Type: onChange, Field Name: Log In Time
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
/* if (isLoading || newValue === '') {
return;
}*/
//Type appropriate comment here, and begin script below
var g = g_form.getValue("u_log_in_time");
var g1 = g_form.getValue("u_log_off_time");
var ajax = new GlideAjax('AjaxDurCalc');
ajax.addParam('sysparm_name','durCalc');
ajax.addParam('sysparm_strt',g);
ajax.addParam('sysparm_end',g1);
ajax.getXMLWait();
alert(ajax.getAnswer());
var answer = ajax.getAnswer();
g_form.setValue('u_log_time', answer);
}
Script include:
var AjaxDurCalc = Class.create();
AjaxDurCalc.prototype =
Object.extendsObject(AbstractAjaxProcessor,{durCalc:function(){
return GlideDuration.subtract(this.getParameter('sysparm_strt'),this.getParameter('sysparm_end'));}});
I tried even with:
ar AjaxDurCalc = Class.create();
AjaxDurCalc.prototype = Object.extendsObject(AbstractAjaxProcessor, {
durCalc: function() {
return gs.dateDiff(this.getParameter('sysparm_strt'),this.getParameter('sysparm_end'), false);
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 05:14 AM
Your g1 variable is wrong. You've set it on u_log_off_time but the field name is u_logoff_time so your end time is a null value which is breaking the calculation. Correct it to below:
var g1 = g_form.getValue("u_logoff_time");
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 05:33 AM
Got it ...
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-23-2018 05:35 AM
How do i get the times in 24Hour format ?????