
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-11-2017 07:53 AM
Does anyone know away to convert a Schedule Date/Time field to GlideDateTime? I'm trying to make it so that when a user adds a user_calendar_event record it sends them an Outlook Appointment but the time isn't caring over right. I did create an Impex Map for the table. So I'm thinking that its because the fields aren't a GlideDateTime, but I'm not sure what the best way to covert the Schedule fields are.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 01:33 PM
So a better explanation of what I'm trying to do is, is that I'm trying to get ServiceNow to send an appointment when a user add something to their resource calendar. The table the calendar uses is user_calendar_event. I can get the invites to send to the user, but the dates are wrong. I've created the Import Export map on the sys_impex_map table as instructed here. I've tried just about everything I can't think of but the results are always the same, it just defaults to the current time.
I've tried pointing dtstart and dtend to start_date_time and end_date_time.
I've also tired converting the two fields to a GildeDateTime, something similar to this background script I came up with while testing (I couldn't get gs.log() or gs.info() to output anything in the script field).
var gr = new GlideRecord('user_calendar_event');
gr.get('1f8c431a13f5c7c05b11345fd144b090');
gs.print(gr.start_date_time.getValue() + ' = ' + gr.start_date_time.getDisplayValue());
gs.print(gr.end_date_time.getValue() + ' = ' + gr.end_date_time.getDisplayValue());
gs.print('');
gs.print('');
var gtStart = new GlideDateTime();
var gtEnd = new GlideDateTime();
gtStart.setDisplayValue(gr.start_date_time.getDisplayValue());
gtEnd.setDisplayValue(gr.end_date_time.getDisplayValue());
gs.print(gtStart.getValue() + ' = ' + gtStart.getDisplayValue());
gs.print(gtEnd.getValue() + ' = ' + gtEnd.getDisplayValue());

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-16-2017 01:33 PM
So a better explanation of what I'm trying to do is, is that I'm trying to get ServiceNow to send an appointment when a user add something to their resource calendar. The table the calendar uses is user_calendar_event. I can get the invites to send to the user, but the dates are wrong. I've created the Import Export map on the sys_impex_map table as instructed here. I've tried just about everything I can't think of but the results are always the same, it just defaults to the current time.
I've tried pointing dtstart and dtend to start_date_time and end_date_time.
I've also tired converting the two fields to a GildeDateTime, something similar to this background script I came up with while testing (I couldn't get gs.log() or gs.info() to output anything in the script field).
var gr = new GlideRecord('user_calendar_event');
gr.get('1f8c431a13f5c7c05b11345fd144b090');
gs.print(gr.start_date_time.getValue() + ' = ' + gr.start_date_time.getDisplayValue());
gs.print(gr.end_date_time.getValue() + ' = ' + gr.end_date_time.getDisplayValue());
gs.print('');
gs.print('');
var gtStart = new GlideDateTime();
var gtEnd = new GlideDateTime();
gtStart.setDisplayValue(gr.start_date_time.getDisplayValue());
gtEnd.setDisplayValue(gr.end_date_time.getDisplayValue());
gs.print(gtStart.getValue() + ' = ' + gtStart.getDisplayValue());
gs.print(gtEnd.getValue() + ' = ' + gtEnd.getDisplayValue());
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-23-2020 02:29 PM
were you able to resolve this issue? I am experiencing the same issue.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 02:21 AM
To convert a Date/Time field to GlideDateTime you can call
var myGlideDateTime = new GlideDateTime(myGlideRecord.getValue("u_my_date_field"));

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-19-2017 06:30 AM
Unfortuattly a Schedule Date/Time field isn't the same as a Date/Time field. It seems Schedule Date/Time extents the String field so the return values are different from Date/Time.
myScheduleDateTimeField.getDispalyValue() seems to return the proper format that a GlideDateTime would accept however the import export map doesn't seem to care that I'm telling it to use this variable that I make in the script.