Ben Vlaeminck

Use of Persistent Variables in consecutive rules

Recommended Posts

Hi all,

I'm New to Persistent Variables... but managed to get them working within 1 rule.

I am a bit confused about the exact 'preparation' to use Persistent Variables in consecutive Call routing rules for a particular user.

As outcome of another Post in this forum , the use of Persistent Variables was the best/only solution.

Now, I want to implement this, and all works fine inside one rule. When Rules are SKipped (from within the rule), in the next rule I need to access the same Persistent Variable as used in the previous rule.

I presume I need to include the GSE Action Block in the next rule and declare (Dim PV and Set as New PV) the Persistent variable again? 

Thanks for your input in these

Share this post


Link to post
Share on other sites

Hello Ben,

 

every GSE rule that makes use of persistent variables needs to use the "Run GSE Action" block to includes them. If they are included into several rules of one of the same user, the server will make sure, their code will only be added once to the resulting vbscript call routing code.

 

If you use your instances of persistent variables within the "Start" block they are globally available in all call routing script of this user. The "Start" block contains global code for the user. The content of a "Insert Script code" block contains local code for the current call routing script.

 

Does this answer your question?

 

Share this post


Link to post
Share on other sites

Hi Tom, thanks for the quick reply.

This answers my question partially.

My first rule where I set the Language, works perfectly, I can see the selected language in the DB table as value of the Persistent Variable.

In the second rule, I already figured out I need to include the GSE Action Block.

Next to that, in that second rule I want to read the value of the Persistent Variable from the table. Here's what I have in a script Block in the second rule:

 

Dim sLanguageForCallId
sLanguageForCallID.Name = "Language_" & PBXCall.CallId
sLanguagePrefix = sLanguageForCallID.Value
 
Should this do the Job? What is missing / wrong?
 
Do I understand correctly that if I place following in the Start Block of the first rule, it is available for all following rules in the same user call routing rules?
Dim sLanguageForCallID
Set sLanguageForCallID = new PersistentVariable
sLanguageForCallID.Name = "Language_" & PBXCall.CallId
 

Share this post


Link to post
Share on other sites

Ben

 

if you place the second code snippet into the start block of any of the active rules of the user, you can use the pv in any of the rules directly:

 

sLanguagePrefix = sLanguageForCallID.Value

 

Share this post


Link to post
Share on other sites

Tom,

Any active rule, but not the first one I presume, because the GSe action is being called to connect to the DB only after that Start block in the first rule.

Is that assumption correct? or does that sequence doens't matter?

Share this post


Link to post
Share on other sites

The sequence doesn't matter at all as VBScript, i.e. The Windows Scripting Engine, don't care. 

 

What happens in behind is, that one large VBScript file is generated from all the rules you have. Every GSE rule is one VBScript function within this larger file. Stuff you put into the start block ends up outside of these functions and is therefore global over in the large file, and therefore global over all rules. 

 

Share this post


Link to post
Share on other sites

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