need client script to subtract two different date/Time fields and result would be stored in another field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 02:21 AM
Hi Guys,
Here i will explain my scenario,
We have two date fields. Those two dates need to be subtracted and the result should be stored in another field.
I need a client script for this.
Could anyone please help me on this.
Thanks in Advance,
Thanks,
Malaisamy
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 02:40 AM
function onChange(control, oldValue, newValue, isLoading) {
var strt = g_form.getValue('<start_field>');//date1
var end = g_form.getValue('<end_field>');//date2
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.setValue('<duration_field>', answer);
}
Script include
Name:AjaxDurCalc
Client callable:checked,client:checked
script:
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
‎10-27-2016 02:47 AM
Hi Balaji,
This i have tried but i am unable to achieve this. I will share my dev instance credentials..could you please help me on this
my Instance: ServiceNow
user: admin
pwd: Riyamalai*1
Table : Test Table(just type in navigation menu);
Calculation fields: Opened date/time, Investigation completed date
Result Field: SI Actual
Please use this and help me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 03:04 AM
I will check....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-27-2016 03:05 AM
Thanks.. I will be waiting for your reply