03-30-2016 07:36 AM
Has anybody played with "Local Variables" and can give me a sample how to work with them?
I'm looking for a way how to create them, read and change values.
I'm trying to create element that reads file, parses it's content and stores values in "local variables". Maybe built-in Math->Set Value element is good enough, but as I understand it can store single variable in one go (one Javascript code block per variable) . Since I'm parsing file content, I don't like to do it multiple times (once per variable).
Thanks!
Solved! Go to Solution.
04-06-2016 02:34 PM
Ervins,
Not used them myself yet but there's a couple of new methods to get and set local variables.
com.audium.server.session.APIBase
public void setLocalVariableData(String variableName, Object value)
com.audium.server.session.ComponentAPI
public Object getLocalVariableData(String variableName)
Paul
04-01-2016 12:54 PM
if you mean call variables, something like this...
var callVars = dialog.getMediaProperties();
Then, access ECC variables like this:
somevariable = callVars["user.ecc_variable_name"];
set a variable
var options = {};
currdialog.updateCallVariable(name, value, options);
04-01-2016 11:53 PM
No, I mean "local variables". A new feature in CVP Call Studio 11.0. you can create/set them using Math>Set Value element.
Example you've given looks like JavaScript from Finesse gadget. It's not what I'm looking for. Example I'm looking for would be in Java.
04-05-2016 04:50 PM
I've used the SetValue element to create Local Variables - you can enter any JavaScript you want into the LocalVariables value field.
Right-click in the Settings tab and select Add Variable. You'll get a field where you can define a var name. For example: TestVar
Then click the ... button to enter one or more lines of JavaScript. Only the very last line of the code will be assigned into the Local Variable named TestVar.
For example, I have a Session Variable named FullName that is of the format LastName,FirstName (ex: Graves,Janine)
That I want to split at the comma.
I created a Local Variable named Position and set its value to this {Data..Session.FullName}.indexOf(",");
Then I can also add another Local Variable in that element, named LastName
Set the Value to {Data..Session.FullName}.substr(0, {LocalVar.Position});
And I can also add another Local Variable in that element, named FirstName
Set the Value to {Data..Session.FullName}.slice({LocalVar.Position}+1);
You can also execute multiple statements (semi-colon separated) within the value field, but I believe only the final statement's value will be assigned into the LocalVariable.
Also, LocalVariables don't display in the Studio Debugger. So if you want to display the result, you could assign the LocalVariables into Session Variables.
Janine
04-06-2016 11:43 AM
Here is some more examples:
Different Types of Variables:
All the user defined variables at session, application and system level will have additional user prefix. e.g. system.user., application.user. , session.user. etc. Any variables without .user., will be treated as immutable variables and can not be modified.
Subflow Parameter Passing and Return value handling:
This approach of setting the parameter will help separating the access of elements and avoiding the subflow access caller flow elements.
This will provide the flexibility of each element being defined independently and linked by the programmer at some later point. As we need the member variables to be available at app development time itself, so that they can be referred within the flow, dynamic creation of the list from subflow-start node to caller node or vice-versa will not be able to handle that and has not been chosen.
Local Variables
varname - This will be the LHS of the expression. If the variable is not created so far, it will be created. [A new hash map will be created for each subflow, with key as the var name and value as a string. The hashmap is deleted when the subflow returns.]
expression - This will be RHS of the expression, which will be evaluated and assigned to the variable.
2. On execution of the SetValue element, it will take the expression as the input and create an entry in the hashmap with the variable name as the key, if it does not exist and assign the value.
global / application / session variable
04-06-2016 02:00 PM
I'm sorry but this answer is to a different question, not to the one I asked.
I am looking for a piece of Java code that would allow me to create & set local variable from my own custom element.
So far there is information how to work with "Set Value" element. I'm building my own element and would like to work create/work with local variables from within that element.
04-06-2016 02:34 PM
Ervins,
Not used them myself yet but there's a couple of new methods to get and set local variables.
com.audium.server.session.APIBase
public void setLocalVariableData(String variableName, Object value)
com.audium.server.session.ComponentAPI
public Object getLocalVariableData(String variableName)
Paul
04-07-2016 02:03 AM
Thanks, Paul !
This is something I can work from.
Is there a new version of JavaDoc for CVP element classes? The only version I can find on developer.cisco.com is for CVP version 9.
Thank you!
Ervins
04-07-2016 02:19 AM
Have a look in Cisco\CVP\VXMLServer\docs\javadocs
04-07-2016 03:29 AM
Got it. Thanks!
12-25-2018 06:03 PM
Question for you Janine. When you use Set Value with {Data..Session.FullName}.substr(0, {LocalVar.Position});,
How do you go Extract the value that is derived?
Since you set the Position to = {Data..Session.FullName}.substr(0, {LocalVar.Position}); does that mean the result would be stored in the {Data.Session.Position} or like {Data.Element.Set_Value.value}?
12-27-2018 12:15 AM
You can use "eval"
Example below:
var str = {Data.Session.pin}; eval(str.length);
12-27-2018 08:19 AM
Hello Gouroke,
I don't think I understand what you mean. So once I use the SET Value Element, create a name called "var" with value of
str = {Data.Session.pin}; eval(str.length);
Then how do I get the output put into a session or element data?
12-27-2018 09:30 AM
Boddol,
Below is a screen shot of setting a Local variable "PIN_Length", which has a value of
var str = {Data.Session.pin}; eval(str.length);
A local Variable is similar to a session variable but you use "LocalVar" instead of "Session" to retrieve it e.g. {LocalVar.PIN_Length}.
You can use the subsitution tag builder as per below.
Regards,
Gerry
12-27-2018 09:57 AM
Thanks. That worked.
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide