Get a first look at what's coming. The Developer Passport Australia Release Preview kicks off March 12. Dive in! 

ATF Run Server Side Script Outputs

ericgilmore
Tera Guru

Is it possible to pass values from a Run Server Side Script test step to proceeding test steps?

After investigating, and finding out that I had to ADD an Output Variable to the Run Server Side Script test step (Automated Test Framework > Administration > Step Configurations > Run Server Side Script > Output Variables), I thought this bit of code would allow me to actually obtain a field value and pass it to proceeding test steps, but no, this doesn't work.

(function(outputs, steps, params, stepResult, assertEqual) {
    var gr = new GlideRecord('problem');
    // gr.get(steps('0bc8dc5d1bd0bd10ee9420ecac4bcb4e').record_id);
	gr.addQuery('sys_id',steps('0bc8dc5d1bd0bd10ee9420ecac4bcb4e').record_id);
	gr.query();
	
	if(gr.next()) {
		outputs.u_jirakey = gr.u_jira_key;
		outputs.table = 'problem';
		// outputs.record_id = gr.insert();
		// outputs.table = 'problem';
	}

})(outputs, steps, params, stepResult, assertEqual);

 

I don't know if this SHOULD show up in the test results, but when I look at the results for this step I see this...
testStep.png

 

Anyone else run into this??

1 ACCEPTED SOLUTION

Elijah Aromola
Mega Sage

Have you attempted to set a static value for those two output variables in your script? Currently it is nested inside your query and I cannot determine if that query is just unsuccessful.

View solution in original post

4 REPLIES 4

Elijah Aromola
Mega Sage

Have you attempted to set a static value for those two output variables in your script? Currently it is nested inside your query and I cannot determine if that query is just unsuccessful.

I did and it worked with the static values. I was able to identify and extract the data I needed, but ultimately we went in another direction.

gurralanavi
Tera Contributor

I am facing the same issue. Could you please let me know what steps you followed in order to resolve the issue?

Ron28
Mega Sage

Having the same issue, output variable isn't updated in the scripted step. I need to return an IP address and had the output variable set up with the IP Address type. It doesn't populate the u_ip_address in the test step result.
Strangely though, to set the output result I used an 'if (gs.nil(outputs.u_ip_address)) {..failed} else {..success}" which sets the result as success.

As per above suggestion I've set the field outputs.u_ip_address with '1.2.3.4' directly but that doesn't show in the step output either. I then changed the type setting from IP Address to String but that doesn't work either. 

I checked a script created by a ServiceNow employee on our instance - that script also sets output variables but do not display in the output fields of the step result.

Any ideas?
Thanks
Ron