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-26-2018 04:58 AM
Nope

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 06:56 AM
Can you please provide your scripts. Did you follow the exact steps mention above? Did you put the exact name of the fields?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2018 12:51 AM
Yes i followed.
Client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
/* if (isLoading || newValue === '') {
return;
}*/
//Type appropriate comment here, and begin script below
var g4 = g_form.getValue("u_log_time");
var g5 = g_form.getValue("u_total_break_time");
var ajax = new GlideAjax('AjaxDurCalcTotal');
ajax.addParam('sysparm_name','durCalcTotal');
ajax.addParam('sysparm_strt2',g4);
ajax.addParam('sysparm_end2',g5);
ajax.getXMLWait();
//alert(ajax.getAnswer());
var answer2 = ajax.getAnswer();
g_form.setValue('u_total_time', answer2);
Script include:
var AjaxDurCalcTotal = Class.create();
AjaxDurCalcTotal.prototype = Object.extendsObject(AbstractAjaxProcessor, {
durCalcTotal: function(){
var duration1 = current.u_log_time; //or wherever your duration1 field is
var duration2 = current.u_total_break_time; //or wherever your duration2 field is
var duration = duration1.subtract(duration2);
var answer2 = duration.getDurationValue();
return answer2;
}
u_log_time and u_total_break_time are duration fields....
u_total_time is also a duration field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2018 12:56 AM
You need to set your duration variables to the values you are passing back in your glide ajax:
var AjaxDurCalcTotal = Class.create();
AjaxDurCalcTotal.prototype = Object.extendsObject(AbstractAjaxProcessor, {
durCalcTotal: function(){
var duration1 = this.getParameter('sysparm_strt2');
var duration2 = this.getParameter('sysparm_end2');
var duration = duration1.subtract(duration2);
var answer2 = duration.getDurationValue();
return answer2;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-27-2018 02:04 AM
yes..i have written the same way firstly...it did not worked
then i have used yours...even it has not worked..,