Page 1 of 1

Script Execution within Menu Tag

Posted: Sat Feb 28, 2009 1:58 am
by hct
I have come to believe it impossible to execute a script on entering a menu tag. Why this was left out of the 2.1 specification, I do not know.

I need to execute a script at the entry of each form and menu element. This works fine for forms, but with menus, neither assign or script can run at the base level. I know that filled/nomatch/noinput can do so, but I need to know if the user entered a menu, regardless of if action was taken.

Further, I understand that I could run a script before entering a menu either doing so before the next call or by passing through a form specifically used to run the script and continue to the menu. However I hope there is some simple, direct means which I have not yet cogitated. Surely other developers have pulled their hair out over this paradox.

Thanks.

IVR code for Script Execution within Menu Tag

Posted: Mon Mar 02, 2009 10:31 am
by support
Hi,

There is one other alternative. You could use the IVR tag, <value>, with the expr attribute to call upon your function.

The value expr attribute would call an ECMAscript function that returns "" and the ECMAscript function, declared elsewhere in your IVR script, could carry out the IVR script.

For IVR example:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?> 
<vxml version="2.0"> 
    <script> <![CDATA[ 
       function runscript(n) 
       {
         //insert script that needs to be run;
         n = "";
         return n;
       } 
    ]]> </script> 

  <menu id="blah"> 
    <value expr="runscript()"/>
    ...
    ...
    ...
  </menu> 
</vxml>
Hope this IVR code sample helps.

Regards,
Plum Support

Posted: Wed Mar 04, 2009 10:38 pm
by hct
Works like a charm. Just the trick I was looking for. Thanks.