##### Define > Actions

# Code Button

Clicking the Code button on the Action Properties window opens the Code for Action <action> dialog box, where <action> represents the Action Name previously selected. The following options allow you to create additional code statements for a specified Action.

## Insert After

Insert a new code line after the currently selected line.

## Insert Before

Insert a new code line before the currently selected line.

## Clear

This command clears the current line.

## Command

The Command window contains a tree structure of the various commands the user can select. Below is a brief description of each command.

### ALERT

Display a message to the user in an alert box.

You can cause an alert box to display a Genesys Agent Scripting field or free form text.

### CAPTURE

Capture the content of a page.

You can capture the content of a page to a field or free form text. It can then be used to create an e-mail, PDF, and so on. Capturing a page also captures any style sheets or images.

### COMMAND

Execute static text, such as a Javascript statement, as a command in the target language, that is, ASP, ASPX, or JSP.

This field allows you to insert additional code in the target language.

### COMMENT

This command allows the user to insert comments into the code.

### DIM

This allows you to manually declare a variable. Variables do not normally need to be declared explicitly. However, declaring a variable manually can specify its type when it is ambiguous.

You can define a variable as a String, Boolean, DateTime, or Number.

### EXECUTE

This command allows you to execute any predefined Genesys Agent Scripting functions.

The area to the right of the command list contains a table with the existing Genesys Agent Scripting actions.

### IF

Execute the following code if the conditions indicated are true. Conditions can be the comparison of one field, variable, or static value to another field, variable or static value.

In an IF command, you can compare an Genesys Agent Scripting field or free form text to another Genesys Agent Scripting field, free form text, or a list of static values from a drop-down list or radio buttons using the operators listed in the screen above. Based on the results, the code entered in the lines after may or may not be executed.

#### ELSE

This command executes the following code if the proceeding IF condition is not true.

#### ELSEIF

This command allows you to have multiple conditional statements. If the preceding IF or ELSEIF statements were not true, then check to see if this condition is true and execute the following code if it is true.

#### ENDIF

This command is used to terminate an IF condition.

You need to place an ENDIF at the end of the IF statement.

### RECALC

This command will recalculate the value for the specified Genesys Agent Scripting Function Field selected from the drop-down list.

### RESPONSE

This field allows you to write a field, variable, or static text to the browser window.

### SET

The command allows you to set a field or variable equal to a field, variable, or static value.

Selecting set allows you to set an Genesys Agent Scripting field or free form text equal to another Genesys Agent Scripting field, free form text, or static value from a drop-down list or radio buttons.

If you are working within a table, using the FOR EACH ROW command, additional options in the drop-down list are also available. You may also set the value for that row’s column or status equal to a field, variable, column, status, or static value where appropriate.

### WHILE

This command allows you to execute following code while the conditions indicated are true. Conditions can be the comparison of one field or variable to another field, variable, or static value.

#### ENDWHILE

This command is used to terminate a WHILE condition.

You need to place an ENDWHILE at the end of the WHILE statement.

### Async Commands

The Async Commands are described below.

#### GET ASYNC CLIENT ID

The async client id tells outside servers how to contact the session. This command allows you capture the async client id and save it to a field.

The async client id can either be saved to a field or as free form text entered when creating the action.

#### PULL VALUE

The PULL VALUE command takes the value of the Listener field and puts it in a regular Genesys Agent Scripting field. This is similar to having a field on the right side of the set command.

The value taken from the Listener field can either be saved to a Genesys Agent Scripting field or as free form text entered when creating the action.

#### PUSH VALUE

The PUSH Value command pushes the data into the Listener field on the server. This is similar to having a field on the left side of the set command.

#### SUBSCRIBE TO MESSAGE

Asynchronous interfaces allow you to send messages to everyone who is subscribed to a specific client id or subject. The SUBSCRIBE TO MESSAGE action command subscribes the user to the subject specified.

The subject can either be the contents of a particular field or free form text entered when creating the action.

#### UNSUBSCRIBE FROM MESSAGE

The UNSUBSCRIBE FROM MESSAGE action command unsubscribes the user from the subject specified. Once a user has been unsubscribed from a subject, he won’t receive any messages sent to that subject.

The subject can either be the contents of a particular field or free form text entered when creating the action.

### Branch Commands

#### BRANCH

This command allows the user to transfer control to another script page.

Once the BRANCH command has been selected, you can then select the process flow, stream, and page to which to branch.

You can also branch to a field if the field is set to contain a process flow, stream, or page list. The value that the field gets set to will determine the page to which the system is directed.

#### GET CONTEXT

This command saves the current context to a field.

#### GET CURRENT PAGE

This command saves the current page value to a field.

#### GET CURRENT PROCESS FLOW

This command saves the current process flow value to a field.

#### GET CURRENT STREAM

This command saves the current stream value to a field.

#### NEXT PAGE

This command causes Genesys Agent Scripting to branch to the next script page. The next script page will either be the next page in the script, or a page referenced in a branching condition on the current page.

#### PREVIOUS PAGE

This command causes Genesys Agent Scripting to branch to the previous script page that was displayed.

#### RESTART

This command allows you to start a new session from the selected page.

### Interface Commands

#### API INTERFACE

This command is used to execute custom code within Genesys Agent Scripting. When this command is selected the screen will be changed to provide a list of existing API Interfaces.

#### DATABASE INTERFACE

This command is used to run a database interface script. When this command is selected, the screen will be changed to provide a list of existing Database Interfaces.

#### XML INTERFACE

This command is used to run an XML Interface script. When this command is selected the screen will be changed to provide a list of existing XML Interfaces.

### Session Commands

#### LOAD SESSION

This command will load a saved session based on the value of the field selected or text entered below.

This command is used in conjunction with the Save command and requires the same field to be selected or text entered in order to load the corresponding session.

#### SAVE SESSION

This command allows you to save a session. Saving a session will store all information (for example, call history, data entered, script navigation) in a temporary location. The information can be retrieved with the load command.

You should use the field list to associate a field value with the save option. This field value will be used to determine how the information is stored and retrieved with the load function. The value of this field needs to be able to uniquely identify the saved session. You can also use free form text to assign an identifier to uniquely identify the session to be saved.

#### CLOSE SESSION

This command will close the current browser window and remove the session.

### Table Commands

#### ADD ROW

This command will cause a new row to be added to the selected table. Values for the new row will come from the current values in the fields associated with the columns in the table.

The Field drop own allows the user to select a table to which to add the row.

#### DELETE ROW

This command will cause the currently selected row in a table to be deleted.

#### FOR EACH ROW

This command allows the user to step through each row in a table. FOR EACH ROW can be nested for nested tables.

The user selects the table from a drop down list of Genesys Agent Scripting tables.

If the user iterates through the rows of a Genesys Agent Scripting table within an action, the user can access columns in the table using column or field references.

Field references should be used when iterating through a table and then executing another action from within that action.

Column references should be used if you subsequently have a Database Interface that updates based on the Genesys Agent Scripting table's flags, as the table flags are set based on column references and not field references.

##### EXIT FOR

This command allows the user to exit the FOR EACH ROW command before reaching the last row in the table.

##### NEXT ROW

This command allows the user to advance to the next row in a table.

The user needs to place a NEXT ROW at the end of the FOR EACH ROW statement.

#### GET TABLE ROW

This command will return the current table row.

#### GET TABLE SIZE

This command will return the number of rows in the table.

#### INSERT ROW

This command will cause a new row to be added to its table. Values for the row will be set to blanks for string fields and zero for numeric fields. Any values entered in the fields that make up the table but are not yet saved into the table will be cleared.

If the user wishes to insert a row with the current values of fields that are contained in the tables, use Add Row instead.

#### REMOVE ALL ROWS

This command allows the user to remove all rows from the specified table including any rows from child tables.

#### SET TABLE ROW

This command will set the current row in the specified table based on the value of the selected field.

#### UNSELECT ALL ROWS

This action will clear all rows from a table. This command will also clear all rows from any table that is contained within the target table.

#### UPDATE ROW

This command will cause the currently selected row in a table to be updated with the values in the fields associated with the columns in the table.

## Previous Action

This button opens up the Previous Action definition for editing, prior to an Edit Action being issued.

## Edit Action

This is used when an Execute command has been selected. It opens the definition of the Action for editing, which is the target of the Execute statement.

## Functions

Whenever the right hand side drop down is set to Free Form, the Function button appears. This allows the user to insert a function into an action.

Clicking the Function button opens the User Defined Function Wizard dialog box.

### Function

Select a function from the list. The items in the lists are taken from the functions created in the User Defined Functions option.

### Template

This shows the user how the function looks and what information needs to be passed to it.

### Next

Clicking Next opens a dialog box requesting a name for the variable.

### Previous

This button will return the user to the previous dialog box.

### Finish

This button will insert the function into the action.

### Cancel

Clicking Cancel will close the dialog box without adding the user defined function to the action.

## Cross Reference

The Cross Reference button allows the user to see where an action is being used.

Clicking the Cross Reference button opens the Object Cross Reference dialog box.