Task Builder Help Globe Icon

Add Navigation Script: Outputs

Use output script to collect and store data from a given host screen so the data can be used as a task output or by subsequent task steps.

You can collect data using the IQAScreen interface. Data is stored using the ITaskData interface. The Usage Tips, located on the top pane of the editor, provide the variable names that are available to you and link you to the Javadocs for more information on the objects the variables represent.

Step outputs, configured prior to scripting outputs, are no longer visible in the designer. The navigation engine will not populate these step outputs as long as the output phase is scripted. If you disable or delete the outputs script, then the original step outputs will again be available.

The following code snippet gets the contents of HostField20 and makes it available for a task output called ScriptOutput1:

 
	//get the value in HostField20
	String strHostField20 = null;
	IFieldData f20 = qaScreen.getField(19);
	if (f20 != null)
	{
		strHostField20 = f20.getText();
	}
	else
	{
		throw new UserScriptException("HostField20 not found on the current screen");
	}
	//and make it available as a task output
	taskData.put("ScriptOutput1", strHostField20);

This next code snippet illustrates how to aggregate the value of 2 host fields as table data when a step will be executed multiple times during a task execution.

In this example the host fields are HostField3 and HostField 5, the names of the table columns are "Column1" and "Column2", and the name of the table is "MyTable":

	//check to see if the table already exists
	ITable table = taskData.getTable("MyTable");
	if (table == null) 
	{
		// the table has not been created yet because this step 
		is being executed for the first time
		// so create it
		String[] columns = {"Column1", Column2"};
		table = taskData.createTable(columns);
	}
	//get the contents of HostField3 and HostField5
	String strHostField3 = null; 
	IFieldData f3 = qaScreen.getField(2);
	if (f3 != null)
	{
		strHostField3 = f3.getText();
	}
	else
	{
		throw new UserScriptException("HostField3 not found on the current host screen");
	}
	String strHostField5 = null; 
	IFieldData f5 = qaScreen.getField(4);
	if (f5 != null)
	{
		strHostField5 = f5.getText();
	}
	else
	{
		throw new UserScriptException("HostField5 not found on the current host screen");
	}
	//create a row of tabular data
	String[] row = {strHostField3, strHostField5};
	//add the row to the table
	table.addRow(row);
	//add the table to the task data collection
	taskData.putTable("MyTable", table);	

After the outputs phase is scripted, you must create the step outputs referenced by your script so that they will be available as task outputs. See Creating Step Outputs Referenced in Output Script for more information.

Disable the Above Script in Step Execution:   Select this option to save your script, but make it unavailable to your task. With this option selected the scripting field is disabled and you cannot edit your script.

Verify Script:   Click this option to verify your script. This will not save changes. If the verification is successful, a message displays in the top pane of the editor. If the verification produces errors, they must be either corrected or the script disabled before you can save the script and proceed with implementing task execution.

Note Output script is not run if the step is encountered during a task reset.
Related Topics
Bullet Adding Scripts to Task Steps
Bullet Creating Step Outputs Referenced in Output Script
Bullet Using Scripts to Replace Portions of Task Steps, Overview
Bullet Task Builder for Screens Help Links
  Footer