- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 02:01 PM
Short Version:
https://developer.servicenow.com/app.do#!/api_doc?v=istanbul&id=c_APIRef.dita gives the following example for using GlideDateTime.before()
var gdt1 = new GlideDateTime("2016-05-09 10:11:12");
var gdt2 = new GlideDateTime("2017-06-12 15:11:12");
gs.info(gdt1.before(gdt2));
However when putting it into a background script it outputs "undefined". Why?
Long Version:
I am trying to build a transform script that treats records differently depending on if a field has a date (stored as string) before 2015-01-01. My idea was to just use GlideDateTime.before() to check if the log_date was before the cutoff date. For example:
case 'OPEN' : //This status + assigned to qrsinv is default method for creating a new asset. Anything with this status before Cutoff date 01/01/2015 - Mark as lost
var splitDate = source.u_log_date.split("/");
var strDate = splitDate[2]+'-'+splitDate[0]+'-'+splitDate[1] + ' 00:00:00';
var gd = new GlideDateTime(strDate);
var cutoff = new GlideDateTime('2015-01-01 00:00:00');
if(gd.before(cutoff)){ //Do my code
}else{// more code
}
break;
I'm starting to think that this isn't viable. Any ideas?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 03:23 PM
Yeah I just ran it in Helsinki and I am getting undefined too. The developer doc you are referring to is Istanbul. Here is for Helsinki:
https://developer.servicenow.com/app.do#!/api_doc?v=helsinki&id=c_APIRef.dita
And before is not defined here, compareTo as mentioned in this Helsinki doc.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-15-2017 03:33 PM
Haha glad you gt it