[ATF] How to retrieve Record Producer variable in another ATF Test step - Server Side Script

Community Alums
Not applicable

How can I retrieve Record Producer Variable value 'Affected services' in another ATF test step - Run Server Side Script ?

 

find_real_file.png

 

Based on this value I have to validate Notification sent.

4 REPLIES 4

U_Viswa
Mega Sage

Hi,

(you didn't mentioned Is Affected services is field on backend table?)

I assume Affected services is a field on backend table.

Just created basic steps in ATF as below to retrive the values selected in Record producer while submition.

   find_real_file.png

 

5.Run server side script: 

 

(function(outputs, steps, params, stepResult, assertEqual) {
	// add test script here

	var STEP_4_SYS_ID= 'a94664da2f7199503bc559a72799b6cf'; // get the step sysid of the record submitted step =4 step
	var step_4_output = steps(STEP_4_SYS_ID).record_id;
	var inc=new GlideRecord('u_my_test');  //This is your Record Producer table
	inc.addQuery('sys_id',step_4_output);
	inc.query();
	if(inc.next()){
		var services=inc.getValue("cmdb_ci");  //Here you get the Affected services value
		outputs.table = 'cmdb_ci';   //table for Affected services value
		outputs.record_id = services;  //Set outpus.record_id to services
		stepResult.setOutputMessage("Successfully collected CI Service : " + outputs.record_id);
		stepResult.setSuccess();
		return true;
	}else { 
		stepResult.setOutputMessage("Failed to Retrive CI record");
		return false; // fail the step
	}

 

Step6 - You can use the Run server side script output value as reference in next steps

 

find_real_file.png

 

 

Try let me know

Thanks

Viswa 

Community Alums
Not applicable

Hello Viswa, thanks for reply.

Affected CI is not a field on a table, it is only variable in Record Producer, which is used in the script of Record Producer to trigger the Notification event.

In my ATF I need to validate this Notification was sent, to notifiers defined per Affected service in another custom table.

At the moment I will do it based on raw values =Cloud, Connected Office, Managed Services.

find_real_file.png

S_59
Tera Contributor

Hi Viswa,

I am trying to retrieve field variables from a  submitted record in ATF.  In step5 "Run server side script" how were you able to get the value of sysid?

var STEP_4_SYS_ID ='XXXXXXXXXXXXXXXXX'

Thanks,

Sai 

Hi S_59,

Below sys_id is step 4 record sys_id;

 

var STEP_4_SYS_ID= 'a94664da2f7199503bc559a72799b6cf';

 Below line retrives the out put of record query from step 4.

var step_4_output = steps(STEP_4_SYS_ID).record_id;