The following example requests the average statistic value for a set of targets in the script block and then uses a delay to indicate when this value will become available to the SCXML session.
<scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml"
xmlns:queue="www.genesyslab.com/modules/queue"
xmlns:dialog="www.genesyslab.com/modules/dialog"
xmlns:statistic="www.genesyslab.com/modules/statistic"
initial="initial">
<state id="initial">
<transition event="interaction.added" target="subscribe"/>
</state>
<state id="subscribe">
<onentry>
<statistic:subscribe object="'az@.A'" statistic="'StatAgentsAvailable'"/>
<statistic:subscribe object="'ag_0002@.GA'" statistic="'StatAgentsAvailable'"/>
</onentry>
<transition event="statistic.subscribe.done" target="delay"/>
<transition event="error.statistic.subscribe" target="error"/>
</state>
<state id="delay">
<onentry>
<send event="'delay'" target="_sessionid" targettype="'scxml'" delay="'2s'"/>
</onentry>
<transition event="delay" target="check"/>
</state>
<state id="check">
<onentry>
<log expr="_genesys.statistic.sData('az@.A', 'StatAgentsAvailable')"/>
<log expr="_genesys.statistic.sData('ag_0002@.GA', 'StatAgentsAvailable')"/>
</onentry>
<transition cond="_genesys.statistic.getAvgData('az@.A,ag_0002@.GA', 'StatAgentsAvailable')==1" target="routing"/>
</state>
<state id="routing">
<onentry>
<queue:submit priority="5" timeout="20">
<queue:targets type="dn">
<queue:target name="'7102'"/>
</queue:targets>
</queue:submit>
</onentry>
<transition event="queue.submit.done" target="exit">
<log expr="'DONE'"/>
<log expr="_genesys.ixn.interactions[0].voice.ani"/>
<log expr="'DONE'"/>
<log expr="_event.data.targetselected"/>
</transition>
<transition event="error.queue.submit" target="error"/>
</state>
<final id="exit"/>
<final id="error"/>
</scxml>