- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2017 02:01 AM
Hi All,
I am creating a REST message with GET method for getting CI details from 3rd party tool. We need to pass a parameter called "CHANGEDATE" while sending the GET method .
" Change date for list of Configuration Items to be returned (for example records modified in last 3 days). If value is empty, all Configuration Item records are returned. "
After Creating REST Message I am calling it from a scheduled job as we need to query on daily basis . Now the requirement is to pass the current date and time for below( Marked in Green) in script . Please Guide.
try {
var r = new sn_ws.RESTMessageV2('name_of_outbound_rest_message', 'get');
r.setStringParameter('CHANGEDATE', 'currentDateTIme'); =============================> Please Guide how to give Current date and time here .
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2017 02:22 AM
Hi Ravishankar,
You should try this...
gs.nowNoTZ()
It returns the current UTC date time. Ex: 2017-05-31 09:21:19
Source: GlideSystem Date and Time Functions - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2017 02:17 AM
HI Ravi,
The method gs.nowDateTime()(GMT) or gs.now() will work.
thanks,
Swati
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2017 02:22 AM
Hi Ravishankar,
You should try this...
gs.nowNoTZ()
It returns the current UTC date time. Ex: 2017-05-31 09:21:19
Source: GlideSystem Date and Time Functions - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2017 02:26 AM
Hi Shiva,
Please guide whether this is correct .
try {
var r = new sn_ws.RESTMessageV2('name_of_outbound_rest_message', 'get');
var dtt = gs.nowNoTZ()
r.setStringParameter('CHANGEDATE', dtt); =============================> Please Guide how to give Current date and time here .
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2017 02:31 AM
Just to be sure I would add a toString to cast your parameter
r.setStringParameter('CHANGEDATE', gs.nowNoTZ().toString() );