ATF for change requests

Poorva Bhawsar
Mega Sage

Hi Community,

 

We are creating ATFs for different type of changes but we are not able to set the value of the planned start date and end date. If we are setting it to any date, later after that date, ATFs will fail.

 

Also, we want to change the planned start date to current date before moving it to the implement state because it should reach the planned start date. Initially we can’t select current date because of restrictions.

 

How to change it using run script?

 

What test step we have to add.

 

Thanks,

Poorva

6 REPLIES 6

brianlan25
Kilo Patron

I created a Server side test step that generates a planned start and end date based on our change window. I call this test step near the beginning of my test.

Description Generation script:

function generateDescription() {
    // the global variable 'step' represents the current glide record
    var description = "Create Start and End date in Current Change window.";
	// your code here
	return description;
}
 generateDescription();

Step execution script: //You will just need to modify it to follow your change schedule. Ours is on Wednesday.

(function executeStep(inputs, outputs, stepResult, timeout) {
    var gdt = new GlideDateTime(gs.nowDateTime()); // getToday
    var currentDay = gdt.getDayOfWeekLocalTime(); // get day of the week
    while (currentDay != 4) { //add day until days of the week is 4 or Thursday due to backend timezone of GMT
        gdt.addDaysLocalTime(1); //add one day
        currentDay = gdt.getDayOfWeekLocalTime(); // rest currentDay
    }
    //set day into string and spit it. Then recreate it with the correct times.
    var wed = gdt.toString().split(' ');
    var wedStart = new GlideDateTime(wed[0] + ' 02:00:00'); //set time to 2 am which equals 6 pm on Wednesday
    var wedEnd = new GlideDateTime(wed[0] + ' 03:00:00'); //set time to 3 am which equeal 7 pm on Wednesday

    outputs.u_planned_start = wedStart;
    outputs.u_planned_end = wedEnd;
    stepResult.setSuccess();

}(inputs, outputs, stepResult, timeout));

Then you will also need to setup output values which is a tab after the Step execution script.

brianlan25_0-1793286281349.png

 

Hello @brianlan25,
Thank you for your response. We tried the approach you suggested, and the dates are calculating correctly. However, the values aren’t being assigned to the output variables we created. I followed your instructions, but I’m still running into this issue. Could you please advise what might be causing it?
Thank you!

 

 

Can you share your code and the out put tab?

Caught the error....There was mismatch in backend names for output variables...It worked...thank you so much