Jump to: navigation, search

Set User Data

The following SCXML strategy shows how to set and update user data for an interaction.

<scxml version="1.0" xmlns="http://www.w3.org/2005/07/scxml" 
	xmlns:ixn="http://www.genesyslab.com/modules/interaction"
	initial="initial">
  
  <state id="initial">
	<transition event="interaction.added" target="setudata" >
		<script>
			_data.ixnid = _event.data.interactionid;
		</script>
	</transition>
  </state>
  <state id="setudata">
	<onentry>
		<script>        
			var data = { details : { name : "Smith, John", age : 45 } };
			_genesys.ixn.setuData( data );
			_genesys.ixn.setuData( { category : 1 } );
		</script>
	</onentry>
	<transition target="update"/>
  </state>
  <state id="update">
	<onentry>
		<script>
			_genesys.ixn.setuData( { category : 2 }, _data.ixnid );
		</script>
	</onentry>
	<transition target="check"/>
  </state>
									
  <state id="check">
	<transition event="interaction.udata.changed" 
		cond="_genesys.ixn.interactions[_data.ixnid].udata.category==2 &amp;&amp; 
		_genesys.ixn.interactions[_data.ixnid].udata.details.name=='Smith, John' &amp;&amp; 
		_genesys.ixn.interactions[_data.ixnid].udata.details.age==45" 
		target="exit" />
	<transition target="error" />
  </state>
  <final id="exit"/>
  <final id="error"/>
</scxml>

Feedback

Comment on this article:

blog comments powered by Disqus
This page was last modified on September 22, 2017, at 05:06.