Section II – Functional Modules > Functional Modules > Action Elements Bottom of Page
| Genesys 8.0 SCXML Technical Reference
< Parameter Elements Events >

## Action Elements

The actions of a functional module will be exposed by a defined XML namespace and elements which can be used in SCXML executable content. The behavior of these actions is somewhat similar to the model of the SCXML `<send>` element (that is, the action follows an asynchronous request pattern):

- Invoking an action (for example, initiating an interaction, starting target selection) behaves similarly to sending an event to the target system.

- Invoking an action is part of the SCXML executable content.

- After invoking an action, the orchestration platform immediately continues to the next statement in the executable content.

- The completion of the action is signalled via an asynchronous functional module event.

- Upon completion and the receiving of the event, the SCXML session may be in any state, and not necessarily in the state which initiated the action.

- The SCXML session will handle the completion event using the `<transition>` element.

#### Restrictions

The following is a list of restrictions with respect to functional module actions:

- Action names should be unique across all the functional module interfaces. Otherwise, a functional module must own and process multiple namespaces and associate the identically named actions to the different namespaces.
- There can only be one functional module that implements a given namespace (for example, you cannot have Functional Module 1 and Functional Module 2 implement www.genesyslab.com/2008/10/interaction ).
- A functional module can implement multiple functional module interfaces under the same namespace (for example, interaction and msgbased interfaces under the interaction functional module namespace www.genesyslab.com/2008/10/interaction ). So you could have `<ixn:disconnect>`, `<ixn:start>`, and `<ixn:sendmessage>`).
- A functional module can implement multiple unique namespaces (for example, Functional Module 1 implements www.genesyslab.com/2008/10/nonvoice and www.genesyslab.com/2008/10/urs ).
- A functional module's action element CANNOT specify any other action element as a child, There is an exception, however, for `<submit>` and `<runtreatments>`. If other action elements are nested in an action element then an error will be thrown during document compilation.

#### Namespace Conventions

The functional module namespaces will be www.genesyslab.com/modules/xxxx , where the xxxx represents the unique name associated with the given functional module.

##### Genesys Functional Modules

The following is a summary of these namespaces and the element naming template for the Genesys functional modules:

Functional Module | Namespace | Element naming template | Actions implemented
--- | --- | --- | ---
queue | www.genesyslab.com/modules/queue | `<queue:xxx>` | Queue Action Elements
interaction | www.genesyslab.com/modules/interaction | `<ixn:xxx>` | Interaction Action Elements, Voice Interaction Action Elements, Msgbased Interaction Action Elements, Chat Interaction Action Elements
dialog | www.genesyslab.com/modules/dialog | `<dialog:xxx>` | Dialog (Treatment) Action Elements
resource | www.genesyslab.com/modules/resource | `<resource:xxx>` | Resource Action Elements
statistic | www.genesyslab.com/modules/statistic | `<statistic:xxx>` | Statistic Action Elements
classification | www.genesyslab.com/modules/classification | `<classification:xxx>` | Classification Action Elements
session | www.genesyslab.com/modules/session | `<session:xxx>` | SCXML Extension Action Elements
webapi | www.genesyslab.com/modules/ws | `<ws:xxx>` | Web API Action Elements

#### <invoke> Versus Action Elements

The SCXML `<invoke>` element is not to be used for action elements. As a result, this element has been limited to a target type of SCXML. This has been done for the following the reasons:

- The syntax is much clearer. Here, you basically have to add an extra `<invoke>` + `<content>` on every single invocation, as opposed to just directly using an XML element as executable content.
- It is clear with executable content that the attributes are evaluated by the engine executing the executable content. In other words, I can define a variable named targetqueue in ECMAScript and if I do `<queue:submit queue="'targetqueue'" .../>`, it is clear that I'm referring to an ECMAScript variable. When specifying inline XML on `<content>`, it is passed unmodified to the specified entity being invoked, preventing us from using anything from our datamodel as part of that XML. Note that this is already the intent of the SCXML specification — `<param>` is used to pass parameters that can be evaluated (via 'expr') from the datamodel.
- Executable XML content with parameters can be compiled and validated more easily than `<invoke>`. When we use `<invoke>`, unless we invent a new language for defining which `<param>` elements are mandatory as opposed to optional as opposed to mutually exclusive, we cannot even do syntax checking. This is made worse by the fact that with `<invoke>`, you need a combination of a 'targettype', and src/`<content>` to even figure out what is being "invoked", since the targettype itself does not identify the operation. With executable content, this is defined by the XSD and can be processed at document compilation time with the appropriate errors thrown. It will be checked by your XML editor when you save your SCXML document. This is very, very important, especially from a performance standpoint, since you will not always be having to validate the `<invoke>` content on both sides (orchestration platform and the target system).
- Running executable XML content gives you full freedom to support cancellation. You just need to have it as part of the domain model you define. In CCXML, for instance, the process started with `<ccxml:createcall>` can be cancelled with `<ccxml:disconnect>`. Just put `<ccxml:disconnect>` in `<onexit>` to accomplish this. However, the important thing is, it does not FORCE you to "cancel" the external system when leaving a state. So if you want to initiate the call and then go do something else in some other states as the call progresses, you do not have to abandon the call attempt.

#### Action Elements Used to Change Functional Module Objects

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

- Define the Appropriate Set of Action Elements to Modify the Object — These actions should cover the following ways to change an object:
  - Add New Properties — This would be the action to add new properties to an object.
  - Update Existing Properties — This would be the action to update existing properties of an object. Note: this action can be merged with the new property action.
  - Delete Properties — This would be the action to delete existing properties from an object.

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

  These actions must follow the rules defined above for any action, plus the following rules:

  - The action's positive response event must provide the object and property updates that were made by the functional module via this action.

- Define the Appropriate Set of Events:

  - Response-Related Events — Both a positive and negative event must be defined for the action, based on the rules and naming conventions defined above.
  - Asynchronous-Related Events — If the object and its properties can be modified asynchronously by an external system (that is, not through an action element), then an event is required to represent this change. The naming convention is the same as defined below in the Events section.

Section II – Functional Modules > Functional Modules > Action Elements Top of Page
| Genesys 8.0 SCXML Technical Reference
< Parameter Elements Events >