- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 07:52 AM
I am trying to add a schedule entry on submission of a record producer that will contain a start date/time and end date/time. This is what i have just to create a base schedule
var newScheduleEntry = new GlideRecord('cmn_schedule_span');
newScheduleEntry.addQuery('schedule', 'Wifi Hotspot');
newScheduleEntry.query();
newScheduleEntry.initialize();
newScheduleEntry.name = 'test 2';
newScheduleEntry.start_date_time = producer.var_checkout_date;
newScheduleEntry.end_date_time = producer.var_return_date;
newScheduleEntry.insert();
Can I get any assistance as to why this isn't working? I believe it has something to do with how the date/time field is formatted but I'm not sure.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 08:22 AM
The reason is because the schedule's start/end times are a different data type than the producer's. You need to convert the glide date time to a schedule date time. See this example (code on the right) for a way to do that.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-12-2016 08:13 AM
Hello Robert,
To add, you can refer sample ex in the below wiki.
Refer section 12.1 in case the req is to create a new record.
Refer section 8.9 in case the req is to query the existing record.
https://wiki.servicenow.com/index.php?title=GlideRecord#initialize