- 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
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
01-19-2016 07:17 AM
That was a quick win.
Thanks again for the quick response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2016 01:13 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2016 05:28 AM
This might result in wrong dates, for example 6th of January may be converted to 1th of June.
I believe this solution is more reliable:
var day = new GlideDateTime();
day.setValueUTC(gr.start_date_time,"yyyyMMdd");