Execute Script


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:

Other Command - Execute Script


Predefined Scripts

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.


Duplicate Data

Choose 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 Change Internal Database window - which you can open from the Data menu.




Exit Command

This script exits a container command when a specific condition is met.


Retry Command

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.




Retry Agent and Continue

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.




Pause Agent

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.




Script Return Value

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:




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.