VoiceGuide IVR Software Main Page
Jump to content

Using Return Variable From Vb Script

Recommended Posts

Hi there,

I have a VBS module in my script with the code below:

 

MODULE: vbGetEffectiveDate

 

' Declare and Set our variables

Dim strDate

 

' Set our date based on the Result Variable

If $RV[modMakeEffective] = 1 Then

strDate = Now()

ElseIf $RV[modMakeEffective] = 2 Then

strDate = DateAdd("d", 1, Now())

End If

 

' Clean up our control characters

strDate = Mid(strDate, 1, InStr(strDate, " ")-1)

 

' Return our result and deallocate

set vg = CreateObject("VoiceGuide.CommandLink")

vg.RvSet($RV_LINEID, "EffectiveDate", strDate)

set vg = Nothing

 

I would like to know how do I use my result variable in another module. Like I'm using it in another Update statement can I do it like this?

 

MODULE: modUpdateStatus

 

Update MessageEvent Set EndDate='$RV[EffectiveDate]', ModDateTime='$RV_MM/$RV_DD/$RV_YY' Where OrgID=$RV[modGetID] And intMsgSourceID=2

Share this post


Link to post

Yes, all this should work.

 

$RV[EffectiveDate] will be replaced by the value specified in strDate

Share this post


Link to post

I've tried everything and it's still returning a blank within my query string. It's not working. Any other suggestions ??

Share this post


Link to post

Could you please post your script and a copy of VoiceGuide's Debug Printout which captures the call, this will allow us to see what happened.

 

When running the script click on VoiceGuide's View menu and select 'Event Trace Log' option - any log information will then appear in this window. You must open the trace window before making the call. You can enable the automatic saving of the logs to files in \log\ directory as well.

When posting traces please .ZIP them up and post them as attachments.

Share this post


Link to post

Ok, I've simplified the script to narrow the problem. I'm still having no luck. I've rebooted the server and I'm still getting nothing. Please keep me posted. I've attached the zip file with my scripts and logs.

OPENS.zip

Share this post


Link to post

The Trace Log did not contain much info. Please set trace level to 9 and then make another test call.

Share this post


Link to post

Guys, I went ahead and set the level to 9 on the trace log as you requested. I've attached the latest version. I'm still getting a vbError on Line 5 Col 5 on the frist vbModule. I've imported my code to VS.Net to make sure there is no malformed syntax. Please let me know what you come up with.

USViking_Trace_Log.txt

Share this post


Link to post

Guys, I figured out why the VBScript was not working properly. After setting the Trace Log Level to 10, I ran through the log and found this ...

 

143524.91 1 cl RvSet EffectiveDate, 12/7/2005

143524.92 1 ERROR: COM interface not supported in this version.

 

Although my code works, it seems that my version of VoiceGuide doesn't support VBScripting. But hence raises the question, why give me a VBScript editor if VBScript is not supported in my version? Hmmmmmmmm ???

 

Thank you again for all your time and effort on this matter. I really appreciate it. I'll look into having our company get the version that supports VBScripting.

Share this post


Link to post

Hey Guys, I wrote a solution below. Since my basic version of VoiceGuide doesn't support COM objects - which means I'm unable to create $RV[xxxx] programatically, I went ahead and did my VBScript below including writing to the SQL database. But you must keep in mind, because COM isn't supported, I would set the Path's property to:

 

on {fail} goto [modThankYou]

 

See in this way I get to update/insert into my database using VBScripting and then when VoiceGuide can't proceed to the next module, because COM isn't supported, it will fail, then I simply tell it "Thank You", because now I know my database has been updated.

 

Script below:

 

 

' This script was designed by Joseph Jagrup

' For USViking LLC 12/05/2005

 

' Declare and Set our variables

Dim strDate

Dim strQuery

 

' Set our date based on the Result Variable

If $RV[modMakeEffective] = 1 Then

strDate = Now()

ElseIf $RV[modMakeEffective] = 2 Then

strDate = DateAdd("d", 1, Now())

End If

 

' Clean up our control characters

strDate = Mid(strDate, 1, InStr(strDate, " ")-1)

 

' If the Organization already have an event in our database then

' Update it, else Insert an event

 

If $RV[modExists_RowCount] > 0 Then

 

strQuery = "Update MessageEvent Set EndDate='" & strDate & "', ModDateTime='$RV_MM/$RV_DD/$RV_YY' Where OrgID=$RV[modGetID] And intMsgSourceID=2"

 

ElseIf $RV[modExists_RowCount] = 0 Then

 

strQuery = "Insert Into MessageEvent (EndDate, ModDateTime) Values ('" & strDate & "', '$RV_MM/$RV_DD/$RV_YY $RV_HH:$RV_NN:$RV_SS')"

 

End If

 

' Open our SQL connection and exectue our query

set cn = CreateObject("ADODB.Connection")

cn.Open "DSN=myDSN;UID=jagrup;PWD=****;Database=myDb"

cn.Execute strQuery

cn.Close

Set cn = Nothing

Share this post


Link to post

A number of different approaches can be used to return data back from a VBScript module or Run Program module.

The easiest way is usually to use the "VGRUNRESULT" result file. Detailed info on this is in the help file's sections on Run Program and Run VBScript.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×