- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 07:19 AM
I know you can set the date field to the current date by doing the following
Set Current DateTime In Field - ServiceNow Wiki
Name: Set Current Date/Time In Field
Type: Client Script
Table:
Description: You can use the following two lines to set the current date and time in a date/time field. This bypasses the problem of getting the value into the proper format and proper timezone:
Parameters:
Script: For more information on running Server Side Script with the client please refer to GlideAjax.
var ajax = new GlideAjax('MyDateTimeAjax'); ajax.addParam('sysparm_name', 'nowDateTime'); ajax.getXML(function () { g_form.setValue('put your field name here', ajax.getAnswer()); });
System Script Include
// Be sure the "Client callable" checkbox is checked var MyDateTimeAjax = Class.create(); MyDateTimeAjax.prototype = Object.extendsObject(AbstractAjaxProcessor, { nowDateTime: function () { return gs.nowDateTime(); } });
How do I set it to two days from the current date? Any help would be appreciated, thank you.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 07:37 AM
MyDateTimeAjax = Class.create();
MyDateTimeAjax.prototype = Object.extendsObject(AbstractAjaxProcessor,
{ nowDateTime: function ()
{
var nd = new GlideDateTime(gs.nowDateTime());
gs.log('current date is :'+nd);
var fd = new GlideDateTime(nd);
fd.addDays(2);
gs.log('future date will be:'+fd);
return fd;
}
});

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 07:37 AM
MyDateTimeAjax = Class.create();
MyDateTimeAjax.prototype = Object.extendsObject(AbstractAjaxProcessor,
{ nowDateTime: function ()
{
var nd = new GlideDateTime(gs.nowDateTime());
gs.log('current date is :'+nd);
var fd = new GlideDateTime(nd);
fd.addDays(2);
gs.log('future date will be:'+fd);
return fd;
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-26-2017 07:41 AM
THANK YOU VERY MUCH!