We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics

How to Send values from One xml form to Another

Questions and answers about IVR programming for Plum DEV

Moderators: admin, support

Post Reply
kishore.inline
Posts: 19
Joined: Mon Jun 21, 2010 4:00 am

How to Send values from One xml form to Another

Post by kishore.inline »

Hi

I have two forms and I want to pass the clickin form customerid to the next form caretaker form.
All the forms values entered in one form should be passed to the next form, how can I achieve this.

with regards
Kishore

<form id="clockin">
<field name="customerid" type="digits">
<grammar root="ROOT" type="application/srgs+xml" mode="dtmf">
<rule id="ROOT" scope="public">
<one-of>
<item repeat="0-255">
<ruleref uri="#digit"/>
</item>
<item> "#" </item>
</one-of>
</rule>

<rule id="digit" scope="public">
<one-of>
<item> 0 </item>
<item> 1 </item>
<item> 2 </item>
<item> 3 </item>
<item> 4 </item>
<item> 5 </item>
<item> 6 </item>
<item> 7 </item>
<item> 8 </item>
<item> 9 </item>
<item> "#" </item>
</one-of>
</rule>
</grammar>

<prompt>
You have selected for Clock In.
</prompt>
<prompt>
Enter Client ID and press Hash to Submit.
</prompt>
<filled>
<if cond="customerid.indexOf('#') != -1">
<assign name="customerid" expr="customerid.toString().replace(/#/,'')"/>
<prompt>
You entered <value expr="customerid"/>. Please wait while we process your information.
</prompt>
<else/>
<prompt>
You entered <value expr="customerid"/>. You must press hash to submit your client ID.
</prompt>
<!--<clear namelist="sendid customerid clockin"/>-->
</if>
</filled>
<noinput>
Sorry, No Input received.
<reprompt/>
</noinput>
<nomatch>
Sorry, Invalid Client ID.
<reprompt/>
</nomatch>
</field>

<subdialog name="sendid" namelist="customerid" src="http://kishore.somee.com/ClientID.aspx">
<filled>
<if cond="sendid.confirmation=='verified'">
<prompt>
Your customer ID was verified.
</prompt>
<goto next="#caretaker"/>
<else/>
<prompt>
Your customer ID was not verified.
</prompt>
<clear namelist="sendid customerid clockin"/>
<goto next="#thankyou"/>
</if>
</filled>

</subdialog>
</form>



<form id="caretaker">
<field name="caretakerid" type="digits?length=11">
<grammar root="ROOT1" type="application/srgs+xml" mode="dtmf">
<rule id="ROOT1" scope="public">
<one-of>
<item repeat="0-255">
<ruleref uri="#digit1"/>
</item>
<item> "#" </item>
</one-of>
</rule>

<rule id="digit1" scope="public">
<one-of>
<item> 0 </item>
<item> 1 </item>
<item> 2 </item>
<item> 3 </item>
<item> 4 </item>
<item> 5 </item>
<item> 6 </item>
<item> 7 </item>
<item> 8 </item>
<item> 9 </item>
<item> "#" </item>
<item> "*" </item>

</one-of>
</rule>
</grammar>
<prompt>
Enter CareTaker ID and Password. Enter CareTakerID followed by Star then Password. And press Hash to Submit.
</prompt>

<filled>
<if cond="caretakerid.indexOf('#') != -1">
<if cond="caretakerid.indexOf('*') != -1">
<assign name="id_pass" expr="caretakerid.toString().split('*')"/>
<assign name="care_id" expr="id_pass[0]"/>
<assign name="care_pass" expr="id_pass[1].toString().replace(/#/,'')"/>
<prompt>
Your CareTaker ID is <value expr="care_id"/>.
Please wait while we process your information.
</prompt>
<else/>
<prompt>
You entered <value expr="caretakerid"/>. You must enter your CareTaker ID followed by star then password.
</prompt>

</if>
<else />
<prompt>
You entered <value expr="caretakerid"/>. You did not press hash, no data was sent.
</prompt>

</if>
</filled>


<noinput>
Sorry, No Input received.
<reprompt/>
</noinput>
<nomatch>
Sorry, Invalid CareTaker ID.
<reprompt/>
</nomatch>
</field>

<subdialog name="sendcaretakerid" namelist="caretakerid" method="post" src="http://kishore.somee.com/CareTakerID.aspx">

<filled>
<if cond="sendcaretakerid.confirmation=='verified'">
<prompt>
Your CareTaker ID was verified.
</prompt>
<goto next="#patient"/>
<else/>
<prompt>
Your CareTaker ID was not verified.
</prompt>
</if>
</filled>

</subdialog>

</form>

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Re: How to Send values from One xml form to Another

Post by support »

Hi Kishore,

In order to pass variables from one form to another in your VoiceXML code, you would want to use global variables, which can be referenced from any form in your code. Below is a short example of how you could accomplish this:

globals.php

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
  <var name="global_var"/>
    <form id="firstform">
        <block>
            <assign name="global_var" expr="1234"/>
            <goto next="#nextform"/>
        </block>
    </form>
    <form id="nextform">
        <block>
            <prompt>
                The global variable is assigned the value <value expr="global_var"/>.
            </prompt>
        </block>
    </form>
</vxml>
Hope this helps.

Regards,
Plum Support

kishore.inline
Posts: 19
Joined: Mon Jun 21, 2010 4:00 am

Re: How to Send values from One xml form to Another

Post by kishore.inline »

If we observe code, there is a grammers tags associated to it, so if fields tags are assigned gloablly, then how to link grammer tags with the fields tag.

The given solution is not helping.

And also let me know how to get a caller ID into assigned to pass it as paramerter to the PHP pages.

with regards
kishore

support
Posts: 3632
Joined: Mon Jun 02, 2003 3:47 pm
Location: Boston, MA
Contact:

Scoped IVR Variables

Post by support »

Hi Kishore,

As you had found, the field variables are not able to be passed between forms. To successfully pass variables between forms, you would need to use variables declared outside of the forms within <vxml>. What you would want to do is declare the variables you'd use before the first form using <var> and then set this variable inside the <filled> using the field variable.

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
  <var name="cust_id"/>
  <var name="caller_id" expr="session.telephone.ani"/>
  <form id="clockin">
    <field name="customerid">
      <grammar/> <!-- This can be the same as you had before. -->
      <prompt>
        You have selected for Clock In.
        Enter Client ID and press Hash to Submit.
      </prompt>
      <filled> <!-- Skipping to answer question -->
        <assign name="cust_id" expr="customerid"/>
        <goto next="#newform"/>
      </filled>
    </field>
  </form>
  <form id="newform">
    <block>
      <prompt> You entered: <value expr="cust_id"/> </prompt>
    </block>
  </form>
</vxml>
By creating a variable outside of the forms, it is not bound by the scope of the forms. This allows you to use this variable anywhere you'd like within the application.

Another thing we noticed is that you're using two different sets of grammars. By declaring the type within the field, you're setting the grammar for the field while also using an explicit grammar within. You don't need to declare the type within the field.

We've also added an additional line to that top code to answer your question about the caller ID. At the start of the document we declared a variable called "caller_id" which we set the session.telephone.ani.

Regards,
Plum Support

Post Reply