- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 01:10 AM
Dear Sir,
I had create two fields in incident, one is 'assign date', another is 'resolved date'.
How can I calculate the date difference between 'assign date' and 'resolved date' by using client script? Then put the result into 'date diff' field.
Thanks.
Best regards,
Ling
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-17-2017 02:08 AM
Hello,
you can use this example from wiki:
Example usage (incident form):
Client script:
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var strt = g_form.getValue('sys_created_on');
var end = g_form.getValue('opened_at');
var ajax = new GlideAjax('AjaxDurCalc');
ajax.addParam('sysparm_name','durCalc');
ajax.addParam('sysparm_strt',strt);
ajax.addParam('sysparm_end',end);
ajax.getXMLWait();
var answer = ajax.getAnswer();
g_form.addInfoMessage(answer);
g_form.setValue('u_dur', answer);
}
Script include (client callable):
var 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
‎05-17-2017 05:48 PM
Problem solved. thanks all.