Need help with ATF run server script step

siddhant3
Kilo Explorer

Hi,
I have an ATF test case wherein I need to validate a date field on the form(i.e. on Service Portal).
As I can't hardcode the date in the Validate Variable Values (SP) step, therefore, I'm using the run server side. I have already built the script include which returns the date.

find_real_file.png

find_real_file.png
But I'm not sure as to how to pass the value to the next step, as I get an error while running the test (pasted below).
find_real_file.png

 I'm new to Automated Test Framework in ServiceNow so I need some help. If you want me to provide some more information, feel free to ask about it.

Thanks

3 REPLIES 3

p_kanczugowski
Tera Guru

Hi! You can pass the output to the subsequent steps using an aptly named outputs object, like so:

outputs.record_id = 'x';

Which can then be accessed in the next step like so:

var recordID = steps(SYS_ID_OF_THE_PREVIOUS_STEP).record_id;

You can read up on the topic here and here. As you can see, what you pass between the steps are generally IDs of the records that you can reference elsewhere.

Hence, I'd construct the class/step script so that its output is a sys_id.

Please mark this response as correct/helpful if this is what you've been looking for! 

I completely agree with you for passing sys_id, but in my case I need to pass a date to the next step. Would it be possible to do so using run server side script?

Joshwa Antony S
Mega Guru

Hi,

You have to return your result to output variable

outputs.record_id = helperAddBusDays(10); // I hope this is function and you are doing this validation

Please take a look at this link : https://community.servicenow.com/community?id=community_question&sys_id=4805b7a8db629700fff8a345ca96...  ==> This is another way of populating dynamic dates to ATF tests.

Regards,

JAS