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

## Action Elements

The following are the statistic-specific actions.

#### <subscribe>

This action allows an application to dynamically subscribe to a particular statistic and object pair for this session.

##### Attribute Details

Name | Required | Type | Default Value | Valid Values | Description
--- | --- | --- | --- | --- | ---
requestid | false | location expression | none | Any valid location expression | This is the location for the request ID that is returned as part of this request. Any data model expression evaluating to a data model location. See SCXML Location Expressions for details. The location's value will be set to an internally generated unique string identifier to be associated with the action being sent. If this attribute is not specified, the event identifier is dropped. This identifier can be tested by the completion event handler to distinguish among several outstanding requests. If this attribute is not specified, the identifier can be acquired from the fetch completion event. Every request must receive a unique identifier.
object | true | value expression | none | Any value expression that returns a valid string that follows the target formats (for details see the Target Formats section) | A value expression which returns the name of the object name associated with this subscription request. The following is the set of valid object types: Agent Agent Group (virtual or real) Campaign Campaign Group Destination Label Interaction Queue Place Place Group Queue (virtual or real) Queue Group Routing Point (virtual and real) See SCXML Legal Data Values and Value Expressions for details.
statistic | true | value expression | none | Any value expression that returns a valid string that represents a valid statistic | A value expression which returns the name of the statistic associated with this subscription request. Any statistic name can be specified except for the following: CallsDistributed CallsAnswered DistributedPercentage DistributedWaitingTime NotDistributedPercentage NotDistributedWaitingTime See SCXML Legal Data Values and Value Expressions for details.
interval | false | value expression | 30 | A value expression which returns an integer that is greater than 5 | A value expression which returns an integer that represents the number of seconds to wait for the interval. See SCXML Legal Data Values and Value Expressions for details. The integer returned must be interpreted as a time interval when an updated value of the statistic is sent.

Note: There can only be one active subscription for a given object and statistic pair and the session. If there is an active subscription for an object and statistic pair and another `<subscribe>` action is invoked, the new request will be rejected with an error event. If the developer wants to change the interval of a given subscription, they will have to `<unsubscribe>` and `<subscribe>` again with the new value.

The following is an example:

    <state id="do_subscribe">
    <datamodel>
    	<data id="reqid"/>
    </datamodel>
    <onentry>
    	<statistic:subscribe requestid="_data.reqid" object="'1234.Q'"
    		statistic="'InVQWaitTime'"/>
    </onentry>
    <transition event="statistic.subscribe.done" target="statex"/>
    <transition event="error.statistic.subscribe" target="statey"/>
    </state>

##### Children

None

##### Events

The following events can be generated as part of this action:

- statistic.subscribe.done — This event is sent when the request has been accepted by the system and the statistic subscription has started for this session.
- error.statistic.subscribe — This event is sent when the request has failed for some reason.
- statistic.update — This event is sent at the end of each time interval while the subscription is active.

#### <unsubscribe>

This action allows an application to unsubscribe from a particular statistic and object pair for this session.

##### Attribute Details

Name | Required | Type | Default Value | Valid Values | Description
--- | --- | --- | --- | --- | ---
requestid | false | location expression | none | Any valid location expression | This is the location for the request ID that is returned as part of this request. Any data model expression evaluating to a data model location. See SCXML Location Expressions for details. The location's value will be set to an internally generated unique string identifier to be associated with the action being sent. If this attribute is not specified, the event identifier is dropped. This identifier can be tested by the completion event handler to distinguish among several outstanding requests. If this attribute is not specified, the identifier can be acquired from the fetch completion event. Every request must receive a unique identifier.
object | true | value expression | none | Any value expression that returns a valid string that follows the target formats (for details see the Target Formats section) | A value expression which returns the name of the object name associated with this subscription request. The following is the set of valid object types: Agent Agent Group (virtual or real) Campaign Campaign Group Destination Label Interaction Queue Place Place Group Queue (virtual or real) Queue Group Routing Point (virtual and real) See SCXML Legal Data Values and Value Expressions for details.
statistic | true | value expression | none | Any value expression that returns a valid string that represents a valid statistic | A value expression which returns the name of the statistic associated with this subscription request. Any statistic name can be specified except for the following: CallsDistributed CallsAnswered DistributedPercentage DistributedWaitingTime NotDistributedPercentage NotDistributedWaitingTime See SCXML Legal Data Values and Value Expressions for details.

The following is an example:

    <state id="do_unsubscribe">
    <datamodel>
    	<data id="reqid"/>
    </datamodel>
    <onentry>
    	<statistic:unsubscribe requestid="_data.reqid" object="'1234.Q'"
    	statistic="' InVQWaitTime'"/>
    </onentry>
    <transition event="statistic.unsubscribe.done" target="statex"/>
    <transition event="error.statistic.unsubscribe" target="statey"/>
    </state>

##### Children

None

##### Events

The following events can be generated as part of this action:

- statistic.unsubscribe.done — This event is sent when the request has been accepted by the system and the statistic subscription has been terminated for this session.
- error.statistic.unsubscribe — This event is sent when the request has failed for some reason.

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