- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2015 12:46 AM
Hi All,
I have two Date/Time field in service catalog form.
1. start date/time
2.End date/time
I want to set start date as current date and time. I have achieved this using javascript:gs.nowDateTime();
for end date/time field , I want the value as start date/time + 36 Hours.
How can I achieve this , Please guide me on this.
Appreciate every Comment on this post.:)
Thanks & Regards
Govind Kumar Sharma
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-02-2015 10:53 PM
Hi All ,
Thanks for reply .
I got solution for this requirement. Client Script Date/Time Functions .
function onLoad() {
var cdt = g_form.getValue('startdate'); //Choose the field to add time from
var addtime = 36; //The amount of time to add
var addtype = 'hour'; //The time type. Can be second, minute, hour, day, week, month, year.
var ajax = new GlideAjax('ClientDateTimeUtils');
ajax.addParam('sysparm_name', 'addDateTimeAmount');
ajax.addParam('sysparm_fdt', cdt);
ajax.addParam('sysparm_addtime', addtime);
ajax.addParam('sysparm_addtype', addtype);
ajax.getXML(doSomething);
function doSomething(response){
var answer = response.responseXML.documentElement.getAttribute("answer");
//You could then take the new Date/Time answer and set the value of another field.
// g_form.setValue('expected_start', answer);
//g_form.enddate.setDisplayValue(answer);
alert("enddate :" +answer);
g_form.setValue('enddate', answer);
}
}
Thanks & Regards
Govind Kumar Sharma

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2015 01:16 AM
Define a script include and use below method to add time. Call the script in reference qualifier
gdt.addSecondsLocalTime
Ex: Modify a GlideDateTime Field Value - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2015 02:39 AM
Hi kalai,
Field type is Data/time.
I can not see any reference qualifier for this filed. Please guide me what need to be done.
Thanks & Regards
Govind Kumar Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2015 02:49 AM
My bad.. Its default value
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2015 01:29 AM
For End date, enter the default value - javascript:gs.hoursAgo(-36);