- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2024 04:46 AM
I'm working on an ATF test for change management and need to set the date/time fields on the change form for 30 mins in the future (planned start), 45 mins in the future (rollback time) and 60 mins in the future (planned end). I'm using this server side script which is working absolutely fine with one exception which is all the dates/times are set to the exact same time, i.e., the exact time the script is run.
It's finding the change sysid and it's updating the fields just fine.... it's just the date/time values are persisting to 'now' rather than adding the minutes I've specified. I swear I've used this method before (albeit outside of ATF) and it worked ok, but this is persisting.
Anybody know what I'm doing wrong? Many thanks in advance.
(function(outputs, steps, params, stepResult, assertEqual) {
//Get the sysid of the change record from the previous record query step
var ChangeSysId = steps("9c820788ebec5e10d2e4ff47bad0cd6e").first_record;
//Set the time for the start, end and rollback fields to be changed to.
var plannedStart = new GlideDateTime();
plannedStart.addMinutes(30);
var plannedEnd = new GlideDateTime();
plannedEnd.addMinutes(60);
var plannedRollback = new GlideDateTime();
plannedRollback.addMinutes(45);
//Perform a GlideQuery and update the change request date/time fields with the times obtained above.
var ChangeQuery = new GlideRecord('change_request');
ChangeQuery.addQuery('sys_id', ChangeSysId);
ChangeQuery.query();
while (ChangeQuery.next()) {
ChangeQuery.start_date.setValue(plannedStart);
ChangeQuery.end_date.setValue(plannedEnd);
ChangeQuery.u_roll_back_time.setValue(plannedRollback);
ChangeQuery.update();
}
})(outputs, steps, params, stepResult, assertEqual);
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2024 05:51 AM
I'm a big boy and figured it out on my own by repeatedly trying different methods on background scripts.... 'addMinutes' wasn't being accepted for some reason but reverting back to 'add' for milliseconds seems to have fixed it.
(function(outputs, steps, params, stepResult, assertEqual) {
//Get the sysid of the change record from the previous record query step
var ChangeSysId = steps("9c820788ebec5e10d2e4ff47bad0cd6e").first_record;
//Set the time for the start, end and rollback fields to be changed to.
var plannedStart = new GlideDateTime();
plannedStart.add(1800000);
var plannedEnd = new GlideDateTime();
plannedEnd.add(3600000);
var plannedRollback = new GlideDateTime();
plannedRollback.add(2700000);
//Perform a GlideQuery and update the change request date/time fields with the times obtained above.
var ChangeQuery = new GlideRecord('change_request');
ChangeQuery.addQuery('sys_id', ChangeSysId);
ChangeQuery.query();
while (ChangeQuery.next()) {
ChangeQuery.start_date.setValue(plannedStart);
ChangeQuery.end_date.setValue(plannedEnd);
ChangeQuery.u_roll_back_time.setValue(plannedRollback);
ChangeQuery.update();
}
})(outputs, steps, params, stepResult, assertEqual);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-05-2024 05:51 AM
I'm a big boy and figured it out on my own by repeatedly trying different methods on background scripts.... 'addMinutes' wasn't being accepted for some reason but reverting back to 'add' for milliseconds seems to have fixed it.
(function(outputs, steps, params, stepResult, assertEqual) {
//Get the sysid of the change record from the previous record query step
var ChangeSysId = steps("9c820788ebec5e10d2e4ff47bad0cd6e").first_record;
//Set the time for the start, end and rollback fields to be changed to.
var plannedStart = new GlideDateTime();
plannedStart.add(1800000);
var plannedEnd = new GlideDateTime();
plannedEnd.add(3600000);
var plannedRollback = new GlideDateTime();
plannedRollback.add(2700000);
//Perform a GlideQuery and update the change request date/time fields with the times obtained above.
var ChangeQuery = new GlideRecord('change_request');
ChangeQuery.addQuery('sys_id', ChangeSysId);
ChangeQuery.query();
while (ChangeQuery.next()) {
ChangeQuery.start_date.setValue(plannedStart);
ChangeQuery.end_date.setValue(plannedEnd);
ChangeQuery.u_roll_back_time.setValue(plannedRollback);
ChangeQuery.update();
}
})(outputs, steps, params, stepResult, assertEqual);