# <goto>

Description

Transitions to one of the following:

- an item in the current form (ex. `<goto nextitem="field_name"/>`)
- a dialog (i.e. form or menu) in the current document (ex. `<goto next="#form_id"/>`)
- a document (ex. `<goto next="URI"/>`)
- a dialog (i.e. form or menu) in a document (ex. `<goto next="URI#form_id"/>`)

Note that using a URI to transition to a document will cause the old document's variables to be lost. Keep this in mind when deciding which syntax to use to transition to a dialog in the current document.

A) Document variables will be lost when transitioning to the current document with a URI reference. For example, if the current document is http://www.voicegenie.com/index.vxml, the document variables will be lost if the following syntax is used to transition to the "foo" dialog in the current document:

`<goto next="http://www.voicegenie.com/index.vxml#foo"/>`

B) Document variables will be retained when transitioning to the current document with an empty URI reference. For example, the document variables will be retained if the following syntax is used to transition to the "foo" dialog in the current document:

`<goto next="#foo"/>`

Syntax

    <goto
        next="URI"
        expr="ECMAScript_Expression"
        nextitem="item"
        expritem="ECMAScript_Expression"
        fetchaudio="URI"
        fetchaudiodelay="time_interval"
        fetchaudiominimum="time_interval"
        fetchhint="safe"
        fetchtimeout="time_interval"
        maxage="integer"
        maxstale="integer"/>

Attributes

Attribute | Description
next | The URI of the dialog (i.e. form or menu) or document to transition to when this `<goto>` is executed. Exactly one of next, expr, nextitem, or expritem must be specified.
expr | An ECMAScript expression to be evaluated and used as the URI of the dialog (i.e. form or menu) or document to transition to when this `<goto>` is executed. Exactly one of next, expr, nextitem, or expritem must be specified.
nextitem | The URI of the form item to transition to when this `<goto>` is executed. Exactly one of next, expr, nextitem, or expritem must be specified.
expritem | An ECMAScript expression to be evaluated and used as the URI of the form item to transition to when this `<goto>` is executed. Exactly one of next, expr, nextitem, or expritem must be specified.
fetchaudio | The URI of audio to play while waiting for the document to be fetched. Optional.
fetchaudiodelay | The length of time to wait at the start of the fetch delay before playing `fetchaudio`. Optional.
fetchaudiominimum | The minimum length of time to play `fetchaudio`, once started, even if the document arrives in the meantime. Optional.
fetchhint | Defines when the next document should be fetched. Optional. safe - only load the next document when needed
fetchtimeout | The length of time to wait for the next document to be fetched before throwing an `error.badfetch` event. Optional.
maxage | Indicates that this document is willing to use a cached copy of the next document only while the age of the cached copy is less than or equal to the number of seconds specified by this attribute. Optional.
maxstale | Indicates that this document is willing to use a cached copy of the next document that has exceeded its expiration time by as much as the number of seconds specified by this attribute. Optional.

Attribute Notes

- An `error.badfetch` event is thrown, if more or less than one of `next`, `expr`, `nextitem`, and `expritem` are specified.
- An `error.badfetch` event is thrown if `next` or `expr` refer to a non-existent dialog (i.e. form or menu), either within the same page, or within a different, existent, page.

Parents

<block>, <catch>, <error>, <filled>, <foreach>, <help>, <if>, <noinput>, <nomatch>

Children

None.

Extensions

- Added `fetchaudiodelay` attribute.
- Added `fetchaudiominimum` attribute.

Limitations/Restrictions

- `<goto>` cannot be used as a child of `<foreach>` when `<foreach>` is a child of `<prompt>`.
- With the `com.voicegenie.STRICTCONFORMANCE` property set to `FALSE`, if a dialog (i.e., form or menu) with `dialog_id` transitions back to itself (i.e. `<goto next="#dialog_id"/>`), the dialog's event counters will be preserved.

Example

    <?xml version="1.0"?>
    <vxml version="2.0" xmlns="http://www.w3.org/2001/vxml">
      <form>
        <block>
          This is the first block.
          <goto nextitem="block2"/>
        </block>
        <block name="block2">
          This is the second block.
          <goto next="#form2"/>
        </block>
      </form>
      <form id="form2">
        <block>
          This is the second form.
        </block>
      </form>
    </vxml>