- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 06:58 AM
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-19-2016 07:10 AM
gr.start_date = current.start_date_time.getDisplayValue();
gr.end_date = current.end_date_time.getDisplayValue();
try this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-31-2016 01:57 AM
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.