Differences

This shows you the differences between two versions of the page.

Link to this comparison view

vendors:cisco:uc:ucce:cvp:js [2025/10/28 16:58] – created gerardorourkevendors:cisco:uc:ucce:cvp:js [2025/10/28 17:01] (current) – [CVP Call Studio - JavaScript (Set Value node)] gerardorourke
Line 3: Line 3:
 Create Local variables (similar to session variables) by using the JavaScript node "Set value" node. Create Local variables (similar to session variables) by using the JavaScript node "Set value" node.
  
-CVP’s JavaScript engine (Rhino) runs on the JVM. That means every Java class is accessible from your JS code using the Packages namespace. Example: java.security.MessageDigest becomes Packages.java.security.MessageDigest in JS. +CVP’s JavaScript engine (Rhino) runs on the JVM. That means every Java class is accessible from your JS code using the Packages namespace. 
-So in the above code, it is calling the Java MessageDigest.getInstance method to get a SHA-256 digest object.+
  
 +Example: java.security.MessageDigest becomes Packages.java.security.MessageDigest in JS.
 +So in the below code, it is calling the Java MessageDigest.getInstance method to get a SHA-256 digest object.
 You can instantiate objects, call methods, and access constants just like in Java. You can instantiate objects, call methods, and access constants just like in Java.
-Here is an JS function which you can use in a Set Value node - to get the SHA256 of a value.+ 
 +Example JS function which you can use in a Set Value node - to get the SHA256 of a value:
  
 ==== SHA 256 Example ==== ==== SHA 256 Example ====
Line 56: Line 58:
 <code JavaScript> <code JavaScript>
 var str = {Data.Session.MyDoubleValue} var str = {Data.Session.MyDoubleValue}
-eval(parseInt(str, 10)); +parseInt(str, 10);
-</code> +
- +
-<code JavaScript> +
-var str = {Data.Session.MyDoubleValue} +
-eval(str | 0);  +
-</code> +
- +
-<code JavaScript> +
-var str = {Data.Session.MyDoubleValue}; +
-myint = ~~str; +
-eval (myint);+
 </code> </code>
  
Line 87: Line 78:
 var enteredNum = {Data.Element.Digits_EnterPhoneNum.value}; var enteredNum = {Data.Element.Digits_EnterPhoneNum.value};
 var e164Num = '+353' + enteredNum.slice(1); var e164Num = '+353' + enteredNum.slice(1);
-eval(e164Num); +e164Num;
-</code> +
- +
-Be careful how strings are returns - I found you had to quote as follows - but not sure why above works - which is also a string +
-i.e. using **eval(mybanana);** doesn't work.  +
- +
-<code JavaScript> +
-var mybanana = 'banana'; +
-eval("mybanana");+
 </code> </code>
  
 <alert type="warning">eval will convert an integer back to a float!</alert> <alert type="warning">eval will convert an integer back to a float!</alert>
-So do no use eval if you want to return an integer. Convert to a string and just have the string as the last line as in the below example.+So do no use eval - actually for any value - you do not need to use the eval - and I believe it is  better not to. 
 +eval is used in the cisco examples. 
 +Just return the string itself.
 <code> <code>
 var pollDurationInt; var pollDurationInt;
  • vendors/cisco/uc/ucce/cvp/js.1761670691.txt.gz
  • Last modified: 2025/10/28 16:58
  • by gerardorourke