Converting GlideDateTime to ScheduleDateTime via record producer (cmn_schedule_span as a 'child' related record)

Josh80
Tera Expert

...Hello.

I'm creating a record producer to create both a parent Schedule and a related Schedule Entry.

Mostly everything else is working with the exception of setting the Time Zone.   Because it's a scheduleDateTime field (on the new entry/span record it's not populating from the record producer.   Is anyone aware of how I append the timezone to the last 2 lines of the script below?     The date and time is passed but not the timezone.

****UPDATE: hardcoding it to set timezone doesn't work either.   Anyone have any suggestions on how to pass the time/date/timezone into the XML formatter on the Schedule Entry page?

Thx

//Create new parent Schedule with related Schedule Span

current.type = "customer";

current.name = producer.name;

// create Schedule Span 1 for Monday-Friday business hours

var spanTask = new GlideRecord('cmn_schedule_span');

spanTask.initialize();

spanTask.name = "Business Hours for: " + producer.name.getDisplayValue();

spanTask.schedule = current.sys_id;

spanTask.u_customer_name = producer.name.getDisplayValue();

spanTask.start_date_time = new GlideScheduleDateTime(producer.sdt);

spanTask.end_date_time     = new GlideScheduleDateTime(producer.edt);

//

producer.sdt.setTZ(producer.time_zone);

producer.edt.setTZ(producer.time_zone);

spanTask.insert();

1 ACCEPTED SOLUTION

Josh80
Tera Expert

Thanks to Ryan at SN.



The answer is below:



spanTask.start_date_time = new GlideScheduleDateTime(producer.sdt.getDisplayValue());


spanTask.end_date_time = new GlideScheduleDateTime(producer.edt.getDisplayValue());



The date/time/timezone is passed into start_date_time field and the record updates correctly.


View solution in original post

1 REPLY 1

Josh80
Tera Expert

Thanks to Ryan at SN.



The answer is below:



spanTask.start_date_time = new GlideScheduleDateTime(producer.sdt.getDisplayValue());


spanTask.end_date_time = new GlideScheduleDateTime(producer.edt.getDisplayValue());



The date/time/timezone is passed into start_date_time field and the record updates correctly.