System information

; End of our loop
same => n,EndWhile()
same => n,Playback(silence/1)
same => n,Playback(vm-goodbye)
same => n,Hangup()
; If no results were found, execute this dialplan
exten => NoResults,1,Verbose(2,No results were found)
same => n,Playback(silence/1)
same => n,Playback(invalid)
same => n,Hangup()
Our example dialplan performs a lookup using the DUNDIQUERY() function and stores
the resulting ID value in the DUNDI_ID channel variable. Using the DUNDIRESULT() func-
tion and the getnum option, we store the total number of returned results in the Number
OfResults channel variable. We then set the ResultCounter channel variable to 1 as our
starting position in the loop.
Using GotoIf(), we check if the ${NumberOfResults} returned is less than one and, if so,
jump to the NoResults extension, where we Playback() “Invalid extension”. If at least
one extension is found, we continue on in the dialplan.
Using the While() application, we check if the ${ResultCounter} is less than or equal
to the value of ${NumberOfResults}. If that is true, we continue on in the dialplan, and
otherwise, we jump to the EndWhile() application.
For each iteration of our loop, the DUNDIRESULT() function is used to save the value at
position ${ResultCounter} to the thisResult channel variable. After storing the value,
we output it to the Asterisk console using the Verbose() application. Following that,
we increase the value of ResultCounter by one using the INC() function. Our loop test
is then done again within the While() loop, and the loop will continue while the value
of ${ResultCounter} is less than or equal to the value of ${Number OfResults}.
Using the same type of logic, we could check for values other than None and, if such a
value is found, ExitWhile() and continue in the dialplan to perform a call to the end-
point. The dialplan logic might look something like this:
[subLookupExtension]
exten => _1XXX,1,Verbose(2,Looking up results for extension ${EXTEN})
; Perform our lookup and save the resulting ID to DUNDI_ID
same => n,Set(DUNDI_ID=${DUNDIQUERY(${EXTEN},extensions,b)})
same => n,Set(NumberOfResults=${DUNDIRESULT(${DUNDI_ID},getnum)})
same => n,Set(ResultCounter=1)
; If no results are found, return 'None'
same => n,GotoIf($[${NumberOfResults} < 1]?NoResults,1)
; Perform our loop
same => n,While($[${ResultCounter} <= ${NumberOfResults}])
; Get the current value
Configuring Asterisk for Use with DUNDi | 521