<< <%SKIN-STRTRANS-SYNTOC%> >> Navigation: Agent Commands > Other Commands > Execute Script |
This command executes a custom .NET script, which is useful in these scenarios:
•Control the command execution flow
•Check for duplicates
•Manual interaction with the agent web browser.
Each script command has a corresponding web element selection, and this element has a corresponding entry in the custom script. At run time, if the selection does not exist on the web page, the web element will be NULL in the script. You can check for NULL elements in the script and execute custom functionality if a NULL is found.
The figure below shows the Configure Agent Command panel after choosing Execute Script from the New Command drop-down:
Click the Script type drop-down to choose a script containing typical functionality. You can use a script just as it is given in the template, or click the Edit Custom Script button to launch a pop-up window to edit the script according to your requirements.
Choose Exit on Duplicate Data in the Script type drop-down to select a script that will examine the data extraction up to a specific point and check for a matching data row. If a duplicate is found, the agent exits a specified container command.
If you want to check for duplicates in the data extraction from a previous agent run, you must ensure that the agent does not replace data every time it runs. This is done on the Internal Database window - which you can open from the Data menu.
See Removing Duplicate Data and Extracting New Data Only for more information about how this script can be used.
Choose Copy Duplicate Data in the Script type drop-down to select a script that will examine the data extraction up to a specific point and check for a matching data row. If a duplicate is found, the agent will copy the duplicate data and all child data to the current data row, and then exit a specified container command.
If you want to check for duplicates in the data extraction from a previous agent run, you must ensure that the agent does not replace data every time it runs. This is done on the Internal Database window - which you can open from the Data menu.
See Reusing Existing Data for more information about how this script can be used.
Choose Copy & Delete Duplicate Data in the Script type drop-down to select a script that will examine the data extraction up to a specific point and check for a matching data row. If a duplicate is found, the agent will copy the duplicate data and all child data to the current data row, and then delete the exiting data row, and lastly exit a specified container command.
If you want to check for duplicates in the data extraction from a previous agent run, you must ensure that the agent does not replace data every time it runs. This is done on the Internal Database window - which you can open from the Data menu.
This script exits a container command when a specific condition is met.
This script deletes the current data row and then exits a container command when a specific condition is met.
This script retries a container command when a specific condition is met. You can control the number of times that the agent will retry a container command by editing the default script and using the RetryCount value in the script parameters.
This script restarts the entire agent and continues where it left off when a specified condition is met.
Typically, you would use this script to completely reset a web browser after an error occurs. The agent continues exactly from the point before the reset, so that if an error keeps occurring at this point, the agent will keep restarting in an infinite loop. To avoid this problem, you can set the status Failed on the current data row, so the agent will move to the next data item when it restarts. This code snippet example sets the data row status to Failed.
args.DataRow.SetStatus(RowStatus.Failed)
This script pauses the agent when a specified condition is met. The agent will display the web browser and allow a user to manually interact with the web browser. The user can press the Continue button to continue processing.
An Execute Script command can control the command execution flow by its return value. The command returns an instance of a class CustomScriptReturn. This class has the following 4 public static methods:
Method |
Description |
static CustomScriptReturn RetryContainer(IContainer container) |
The agent will retry the specific container command. The container command must be a parent of the current command. |
static CustomScriptReturn ExitContainer(IContainer container) |
The agent will exit the specific container command. The container command must be a parent of the current command. |
static CustomScriptReturn Pause() |
The agent pauses and displays an agent web browser, which allows a user to interact with the web browser before continuing processing. |
static CustomScriptReturn Empty() |
The agent continues its normal executing flow. |