Section II – Functional Modules > Functional Modules > Functions Bottom of Page
| Genesys 8.0 SCXML Technical Reference
< Object Model Parameter Elements >

## Functions

This defines the set of ECMAScript functions that can be used on the object model for this functional module interface. These functions can be used from ECMAScript expressions and within the `<script>` element or any other SCXML executable content section. The criteria for using a function versus an action element are:

- The action must be immediate (that is, it cannot block).

- The action does not generate any events.

- The action does not affect the state of an object.

- The action does not return a property of a defined ECMAScript object. This information should be accessed through the properties of the given object.

Genesys strongly discourages the exposure of functionality or actions via ECMAScript functions. Action elements are preferred over functions because they allow our schema to define what actions are valid, what parameters they must pass, and so on. Therefore action elements are less error-prone and more in line with the SCXML specification.

Functions can be used for the following types of actions:

- Actions that transform or format data or properties (for example, time_DateInZone).

- Actions that set or change a functional module or interface's behavior with respect to the given session (for example, _genesys.queue.CheckAgentState) and the action elements that are used during this session.

All functions will be function properties of the appropriate functional module object. For example, _genesys.queue.reserveTargets().

#### Restrictions

The following is the list of restrictions with respect to functional module functions:

- Function names should be unique across all the functional module interfaces or else a functional module must own and process multiple functional module root names and associate the same name functions to the different functional module root names. For example, if the Interaction interface has function "fna" and the Queue interface has function "fna" then the functional module must have two functional module root object names (_genesys.fmx1.fna and _genesys.fmx2.fna).

#### Naming Conventions

The following is the naming convention that we will use for all ECMAScript functions which can be used within the session:

- _genesys.FMname.functionname() — This is the convention for ECMA functions — the function will be a function property of the appropriate functional module object and will follow the ECMAScript conventions.

For example, _genesys.session.ActiveServerName()

##### Genesys Functional Modules

The following is a summary of all the functional module root objects that will be supported by Genesys functional modules:

Functional module | Function root | Functions implemented
--- | --- | ---
queue | _genesys.queue | Queue Functions
interaction | _genesys.ixn | Interaction Functions, Voice Interaction Functions, Msgbased Interaction Functions, Chat Interaction Functions
dialog | _genesys.dialog | Dialog (Treatment) Functions
resource | _genesys.resource | Resource Functions
statistic | _genesys.statistic | Statistic Functions
classification | _genesys.classification | Classification Functions
session | _genesys.session | SCXML Extension Functions
webapi | _genesys.ws | Web API Functions

#### Functions Used to Change Functional Module Objects

A function module has three ways it can change the value of a given functional module object or property. One of these ways is through a function. The following is the model that should be used for providing this functionality:

- Define the Appropriate Set of Functions to Modify the Object — These functions should cover the following ways to change an object:

- Add New Properties — The function to add new properties to an object.
- Update Existing Properties — The function to update existing properties of an object. Note: this function can be merged with the new property function.
- Delete Properties — The function to delete existing properties to an object.

The names of these functions can be whatever the function module developers feel appropriate for the object as long as they adhere to the naming conventions for functions (see above for details).

The following are the rules on how these functions must behave:

- The functions must update the object immediately so that it can be used by executable content right after the function has finished making the changes.
- If the execution of the function requires the object-related changes to be made on an external system, then notification of the success of these changes must be reflected in any response-related events.

- Define the Appropriate Set of Events:
  - Response-Related Events — If the execution of a function requires the object-related changes to be made on an external system, then only a positive response event is needed. This event reflects that the change associated with the function was made in the external system. This event should NOT be documented to application developers since the object should have already been updated in the object model. This is only needed to allow the SCXML engine to handle race conditions with respect to asynchronous object changes. The naming convention is fmname.functionname.fndone. fmname is the name of the function module. functionname is the name of the function which was performed.

  Note: a negative response event is not needed because it is assumed that the object is updated (that is, it is behaving like a real function). If there is a problem, then more than likely other functions and action elements in the application will fail due to the problem and notify the application appropriately.

  - Asynchronous-Related Events — If the object and its properties can be modified asynchronously by an external system (that is, not through a function or action element), then an event is required to represent this change. The naming convention is fmname.eventname. fmname is the name of the function module. eventname is the name of the event which represents the object that is changing. This is the standard event naming convention described below.

  If none of these conditions occur then there is no need to have events associated with object modification via a function.

Section II – Functional Modules > Functional Modules > Functions Top of Page
| Genesys 8.0 SCXML Technical Reference
< Object Model Parameter Elements >