Hi Folks,
I can't figure out why the variable highlighted in red is undefined within the script. Your help is very much appreciated.
Thanks...Scott
<vml ...
<vxml ....
<var name="invitation_code"/>
<form id="invitation">
<field name="inv_code" type="digits?length=8">
<prompt bargein="false">
We sent you an invitation email. Please enter your unique 8 digit invitation code included in this email.
</prompt>
<filled>
<assign name="invitation_code" expr="inv_code"/>
</filled>
<noinput count="1">
<prompt bargein="false">
Sorry, I didn't hear you.
</prompt>
<reprompt/>
</noinput>
<noinput count="2">
<prompt bargein="false">
You did not enter anything. Your unique 8 digit invitation code is included in your invitation email. Please enter it now.
</prompt>
<reprompt/>
</noinput>
<noinput count="3">
<prompt bargein="false">
You seem to be having some trouble. Please contact our support team at the telephone number included in your invitation email.
</prompt>
</noinput>
</field>
<block>
<log label="scottlog">
inv_code is <value expr="inv_code"/> invitation_code is <value expr="invitation_code"/>
</log>
</block>
<!-- call API to verify invitation code and request activation code -->
<script>
// <![CDATA[
var json_data = new Object();
json_data.orgid = String(orgid);
json_data.action = "get";
json_data.cid = invitation_code;
var json_string= JSON.stringify(json_data);
// ]]>
</script>
<block>
<log label="scottlog">
JSON data is <value expr="json_string"/>
</log>
</block>
</form>
We've Moved! Please visit our new and improved forum over at our new portal: https://portal.plumvoice.com/hc/en-us/community/topics
Undefined variable in Javascript?
Re: Undefined variable in Javascript?
Hello,
The issue is the order in which your code is being executed. Each time a new scope is executed all of the ECMAScript elements are executed in the order they appear at that scope. So your script would do the following:
1. create the "invitation_code" variable (as undefined).
2. load the "invitation" form.
3. create the "inv_code" variable (as (undefined).
4. the <script> code block is executed.
5. the "inv_code" field is executed.
6. each of the <block> sections are executed in document order.
In order to get the <script> to execute after the <field> you can move it into one of the <block> sections that are after the <field> tag.
Regards,
Plum Support
The issue is the order in which your code is being executed. Each time a new scope is executed all of the ECMAScript elements are executed in the order they appear at that scope. So your script would do the following:
1. create the "invitation_code" variable (as undefined).
2. load the "invitation" form.
3. create the "inv_code" variable (as (undefined).
4. the <script> code block is executed.
5. the "inv_code" field is executed.
6. each of the <block> sections are executed in document order.
In order to get the <script> to execute after the <field> you can move it into one of the <block> sections that are after the <field> tag.
Regards,
Plum Support
Plum Support
http://www.plumvoice.com
http://www.plumvoice.com