
- 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
06-12-2018 10:03 PM
Try:
gr.start_date_time.getGlideObject(); //should be a datetime object in the current timezone ?
or
var a = new GlideScheduleDateTime()
a.setValue(gr.start_date_time);
a //should be a datetime object in the current timezone ?
gr.getDisplayValue('start_date_time') //string representation of the date/time in UTC "08-04-2017 18:00:00"