Get Value of Schedule Entry start and end dates

travuswarren
Giga Contributor

Hello all,

I am attempting to retrieve the values of the start and end dates from a schedule entry to populate a change requests Planned start date and Planned End date fields.   I see that the two format types differ from Schedule Date/Time - Schedule Entry to Date/Time - Change Request, which may be causing me issues. The script log says that the value if start_date_time = 20160119T002000 as an example. Below is my business rule attempt but the values on the change record are currently null after an update.

function onAfter(current, previous) {

var gr = new GlideRecord('change_request');

  gr.addQuery('sys_id', current.u_change_number);

  gr.query();

  while(gr.next()){

  gr.start_date = current.start_date_time;

  gr.end_date = current.end_date_time;

  gr.update();

}

}

Thanks in advance.

1 ACCEPTED SOLUTION

Anurag Tripathi
Mega Patron
Mega Patron

  gr.start_date = current.start_date_time.getDisplayValue();  


gr.end_date = current.end_date_time.getDisplayValue();



try this



-Anurag

View solution in original post

5 REPLIES 5

using getDisplayValue(); with any date will return the date tiem in the current user's date time format and time zone.



Basic idea is to convert both dates to same time cone and format before doing any calculation on it.


-Anurag