Differences
This shows you the differences between two versions of the page.
| vendors:cisco:uc:ucce:cvp:js [2025/10/28 16:58] – created gerardorourke | vendors: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 | ||
| ==== 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, | + | parseInt(str, |
| - | </ | + | |
| - | + | ||
| - | <code JavaScript> | + | |
| - | var str = {Data.Session.MyDoubleValue} | + | |
| - | eval(str | 0); | + | |
| - | </ | + | |
| - | + | ||
| - | <code JavaScript> | + | |
| - | var str = {Data.Session.MyDoubleValue}; | + | |
| - | myint = ~~str; | + | |
| - | eval (myint); | + | |
| </ | </ | ||
| Line 87: | Line 78: | ||
| var enteredNum = {Data.Element.Digits_EnterPhoneNum.value}; | var enteredNum = {Data.Element.Digits_EnterPhoneNum.value}; | ||
| var e164Num = ' | var e164Num = ' | ||
| - | eval(e164Num); | + | e164Num; |
| - | </ | + | |
| - | + | ||
| - | 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); | + | |
| - | + | ||
| - | <code JavaScript> | + | |
| - | var mybanana = ' | + | |
| - | eval(" | + | |
| </ | </ | ||
| <alert type=" | <alert type=" | ||
| - | 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. | ||
| < | < | ||
| var pollDurationInt; | var pollDurationInt; | ||