Outputs variable of ATF Serverside script

Nitesh Balusu
Giga Guru

Hello Developers,

 

I need to output the result of a serverside script that i have written to use in the next step of ATF. the result of the script is a string which looks something like this "/api/now/table/incident/e1ce0900dbc123c075dd9837db961968". Please take a look at script and let me know how the variable "jsonresult_response" needs to be passed to the next step.

Thanks.

 

(function(outputs, steps, stepResult, assertEqual) {

	var jsonresult_response;
	var record_id;

	var res= new GlideRecord("sys_atf_test_result_item");
	res.addQuery('step','2f927cc8db41e3c4af4df35aaf96191c');
	res.orderByDesc("sys_updated_on");
	res.setLimit(1);
	res.query();

	while(res.next()) {

		var jsonresult=res.output;
		
		
		var startindex = jsonresult.indexOf("/api/now/table/incident/");
		var endindex = jsonresult.indexOf("Cache-control");
		jsonresult_response=jsonresult.substring(startindex,endindex);
		
		outputs.record_id=jsonresult_response;
		gs.info("output is "+outputs.record_id);
	}
		

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