Page 1 of 1

TypeError: MenuEcma has no properties line 1

Posted: Wed May 11, 2011 10:57 am
by rquant
I have a vxml form that reads from an xml page. On the first pass everything is fine but if I try to read again from the same xml page I get an error.

Code: Select all

<form id="ChooseNextMenu">
        <block>
            <assign name="CurrentPage" expr="VxmlPage" />
            <assign name="CurrentForm" expr="'ChooseNextMenu'" />
            <assign name="ruleid" expr="MenuEcma.GrammarNeeded.toString()" />
            <log expr="'Presenting next menu options.'" />
            <assign name="SpeedAddressSpeech" expr="speakNumberDigits(MenuEcma.SpeedAddress)" />
        <log expr="'Rule for root= ' +  MenuEcma.GrammarNeeded.toString()" />
            <prompt>
                <foreach item="ChildMenu" array="MenuEcma.ChildrenMenus" >
                    <audio expr="AudioUrl + 'For.wav'">For</audio>
                    <audio expr="RecordingsUrl + ChildMenu.Recording.Filename" >
                        <value expr="ChildMenu.Tts.toString()" />
                    </audio>
                    <audio expr="AudioUrl + 'Press_' + ChildMenu.ChoiceOnPage + '.wav'">, press
                        <value expr="ChildMenu.ChoiceOnPage.toString()" />
                    </audio>
                    <break time="400ms" />
                </foreach>
            </prompt>
            <prompt cond="EmptyMenu == false && IsMainMenu == false">
                <break time="350ms" />
                <audio expr="AudioUrl + 'SpeedAddress.wav'">The speed address for this menu is</audio>
                <audio expr="AudioUrl + 'Pound.wav'">pound</audio>
                <foreach item="AudioItem" array="SpeedAddressSpeech" >
                    <audio expr="AudioUrl + AudioItem.Wave" >
                        <value expr="AudioItem.Tts.toString()" />
                    </audio>
                </foreach>
                <audio expr="AudioUrl + 'Pound.wav'">pound</audio>
                <break time="300ms" />
            </prompt>
        <goto next="#Start" />
This is the xml

Code: Select all

<Response>
  <ReturnCode>0</ReturnCode>
  <ReturnMessage>Successful Menu Retrieval</ReturnMessage>
  <Menu>
    <BargeInEnabled>false</BargeInEnabled>
    <SpeakTimestamp>true</SpeakTimestamp>
    <Recording/>
    <MessageCount>1</MessageCount>
    <ChildrenMenuCount>4</ChildrenMenuCount>
    <GrammarNeeded>four</GrammarNeeded>
    <HasMorePages>false</HasMorePages>
    <LastMessageUpdate>05/09/11 02:28 PM</LastMessageUpdate>
    <Messages>
      <Message>
        <MessageID>51</MessageID>
        <TTS>This is the Instant information Hot line Global Message</TTS>
      </Message>
    </Messages>
    <ChildrenMenus>
      <ChildMenu>
        <ChildMenuID>46</ChildMenuID>
        <ChoiceOnPage>1</ChoiceOnPage>
        <ChildTTS>Power outages, </ChildTTS>
        <ChildRecording/>
      </ChildMenu>
      <ChildMenu>
        <ChildMenuID>47</ChildMenuID>
        <ChoiceOnPage>2</ChoiceOnPage>
        <ChildTTS>Reporting a gas leak</ChildTTS>
        <ChildRecording/>
      </ChildMenu>
      <ChildMenu>
        <ChildMenuID>50</ChildMenuID>
        <ChoiceOnPage>3</ChoiceOnPage>
        <ChildTTS>Option 3</ChildTTS>
        <ChildRecording/>
      </ChildMenu>
      <ChildMenu>
        <ChildMenuID>49</ChildMenuID>
        <ChoiceOnPage>4</ChoiceOnPage>
        <ChildTTS>Option 4.</ChildTTS>
        <ChildRecording/>      </ChildMenu>
    </ChildrenMenus>
  </Menu>
</Response>
This is the error I get when I try to read this xml again.
"TypeError: MenuEcma.ChildrenMenus has no properties line 1"

Please advise on how I can get the PlumVoice Platform to correctly read the xml file the second time around.
Thanks

Re: TypeError: MenuEcma has no properties line 1

Posted: Wed May 11, 2011 4:42 pm
by support
Hi rquant,

We've come up with a simplified version of your example (since we don't have a copy of the JS objects you're referencing in your code) that uses the <data> tag to reference the XML file and read through them in a <foreach> tag. The example also demonstrates how to replay all the items from your XML within the <foreach> tag.

rquant.php:

Code: Select all

<?php
header("Content-type: text/xml");
echo("<?xml version=\"1.0\"?>\n");
?>
<vxml version="2.0">
<property name="documentmaxage" value="0s"/>
<form id="ChooseNextMenu">
<data name="menuecma" src="rquant.xml" maxage="0s"/>
<script>
var choices = new Array();
choices[0] = new Object();
choices[0].childtts = menuecma.documentElement.getElementsByTagName('ChildMenu').item(0).lastChild.toString();
choices[0].pagechoice = menuecma.documentElement.getElementsByTagName('ChildMenu').item(0).firstChild.toString();
choices[1] = new Object();
choices[1].childtts = menuecma.documentElement.getElementsByTagName('ChildMenu').item(1).lastChild.toString();
choices[1].pagechoice = menuecma.documentElement.getElementsByTagName('ChildMenu').item(1).firstChild.toString();
choices[2] = new Object();
choices[2].childtts = menuecma.documentElement.getElementsByTagName('ChildMenu').item(2).lastChild.toString();
choices[2].pagechoice = menuecma.documentElement.getElementsByTagName('ChildMenu').item(2).firstChild.toString();
choices[3] = new Object();
choices[3].childtts = menuecma.documentElement.getElementsByTagName('ChildMenu').item(3).lastChild.toString();
choices[3].pagechoice = menuecma.documentElement.getElementsByTagName('ChildMenu').item(3).firstChild.toString();
</script>
<field name="mymenu">
  <prompt>
    Please select one of the following choices.
    <break time="500ms"/>
    <foreach item="choice" array="choices">
      For <value expr="choice.childtts"/>, enter <value expr="choice.pagechoice"/>
      <break time="500ms"/>
    </foreach>
  </prompt>
  <grammar type="application/srgs+xml" root="ROOT" mode="dtmf">
    <rule id="ROOT">
      <one-of>
        <item>1</item>
        <item>2</item>
        <item>3</item>
        <item>4</item>
        <item>*</item>
      </one-of>
    </rule>
  </grammar>
  <filled>
    <if cond="mymenu.indexOf('*') != -1">
      <goto next="#ChooseNextMenu"/>
    <else/>
      <prompt>
        You entered <value expr="mymenu"/>.
      </prompt>
    </if>
  </filled>
</field>
</form>
</vxml>
rquant.xml:

Code: Select all

<Response>
  <Menu>
    <ChildrenMenus>
      <ChildMenu>
        <ChoiceOnPage>1</ChoiceOnPage>
        <ChildTTS>Power outages, </ChildTTS>
      </ChildMenu>
      <ChildMenu>
        <ChoiceOnPage>2</ChoiceOnPage>
        <ChildTTS>Reporting a gas leak</ChildTTS>
      </ChildMenu>
      <ChildMenu>
        <ChoiceOnPage>3</ChoiceOnPage>
        <ChildTTS>Option 3</ChildTTS>
      </ChildMenu>
      <ChildMenu>
        <ChoiceOnPage>4</ChoiceOnPage>
        <ChildTTS>Option 4.</ChildTTS>
      </ChildMenu>
    </ChildrenMenus>
  </Menu>
</Response>
From this example, the VXML reads through each of the items using a <foreach> tag and references those items from the XML using a <data> tag. Also, note that if the user enters the * key with their keypad, the application loops back to the beginning of the <form> to replay each of the items.

Hope this helps.

Regards,
Plum Support