Page 1 of 1

Root.xml and managing state

Posted: Wed Jul 03, 2013 10:55 am
by SethDerrick
I'm having no luck getting the root.xml document to work as a state management tool. I can get the sample at http://www.plumvoice.com/docs/dev/devel ... otdocument to work but for some reason, using the exact same framework in my own forms doesn't work. The source xml I've written can be seen here: http://pastebin.com/BhxNN1ui

I have other questions but I'll keep to "one post, one topic" and post those other issues in another topic.

TIA,
Seth

Re: Root.xml and managing state

Posted: Wed Jul 03, 2013 11:35 am
by support
Hi Seth,

In the code example you have provided, you assign the variable "ichipnumber" with the value of "'squeak'" in English_GetiChipNumberPt1.xml and attempt to fetch it in English_GetiChipNumberPt2.xml. As the root document documentation states:
Keep in mind that for each new call, the root document is loaded separately.
Because there is no transition from English_GetiChipNumberPt1.xml to English_GetiChipNumberPt2.xml, the state the root document provides is lost. If you wish to maintain the state within a single call, please use a <goto> or <submit> tag to transition from one document to another. If instead you wish to keep the state across different calls, this feature would have to be implemented on your end.

Regards,
Plum Support

Re: Root.xml and managing state

Posted: Wed Jul 03, 2013 12:49 pm
by SethDerrick
In English_GetiChipNumberPt1.xml the var ichipnumber is assigned the val 'squeak' and then four lines later I hear only the "And the value of eye chip number in root is". I do not hear "squeak" added to the line. Also...that line 70 (these are pastebin line numbers btw, not line numbers from my code) was put in to test.

The actual flow is that I enter English_GetiChipNumberPt1.xml which calls Root.xml (line 66), then I do a <subdialog> to English_CollectiChipNumber.xml which also calls Root.xml (line 87). There is also a call to Root.xml in English_GetiChipNumberPt2.xml (line 129). So there is a call to Root.xml across all page transitions, meaning an assignment to the var ichipnumber on any of those three pages/forms should be available to the other two. But when I had the instruction "<assign name="ichipnumber" val="chipnumber"/>" between the <filled> tag and the <prompt> tag (lines 105 and 106) I did not have access to its value when English_CollectiChipNumber.xml returned (line 119) to English_GetiChipNumberPt1.xml

This is the exact same framework as is described in the Root documentation. There is never a transition to a page that doesn't call to Root.xml. In my understanding, English_GetiChipNumberPt1.xml is analogous to the Page1.xml in the documentation and English_CollectiChipNumber.xml is analogous to Page2.xml in the documentation. Two pages that each call Root.xml with one page doing the assigning and the other page retrieving the value. What am I missing?

Re: Root.xml and managing state

Posted: Wed Jul 03, 2013 3:43 pm
by support
Hi Seth,

In English_GetiChipNumberPt1.xml, you did not hear "squeak" added to the line because the variable "ichipnumber" was not assigned correctly. You would have to use the "expr" attribute to assign a value to a variable:

Code: Select all

<assign name="ichipnumber" expr="'squeak'"/>
Please check the documentation for the <assign> tag for more information.

Regarding your second point, it might be useful to think of subdialogs as new VXML documents that execute in a new context, and thus load its own root documents. As such, they are unable to access the root variables from the parent document. However, you can have the subdialog <return> the information you need, and then set the root variable to the returned value in the parent document. Please refer to the example below:

English_GetiChipNumberPt1.xml

Code: Select all

<?xml version="1.0"?>
<vxml version="2.0" application="http://66.196.252.10/plum/GeneralForms/Root.xml">
  <form>
    <subdialog name="info" src="http://66.196.252.10/plum/EnglishForms/English_CollectiChipNumber.xml" namelist="ichipnumber"/>
    <block>
      <assign name="ichipnumber" expr="'squeak'"/>

      <!-- Assign the root variable to the returned variable from the subdialog. This also overrides the initial 'squeak' value. -->
      <assign name="ichipnumber" expr="info.chipnumber"/>

      <prompt>
        we're back.
        You entered <value expr="info.chipnumber"/>.

        <!-- This should now say: "And the value of eye chip number in root is (some number)" -->
        And the value of eye chip number in root is <value expr="ichipnumber"/>.

        Goodbye.
      </prompt>
     
    </block>
  </form>
</vxml>
Please check the documentation on Data Exchange for more information about information flow between documents and subdialogs.

Hope this helps,
Plum Support