Initial SC6 JavaScript example
This is an example of calling a JavaScript function from the ScriptLibrary from a Display Option. I am calling updateEmail funciton from the operatorFunctions ScriptLibrary record that is delivered OOB with ServiceCenter 6.0.
- Enter the call in one of the javascript fields. For instance, either the Pre Javascript (javascript.pre) or Post Javascript (javascript.post) fields in displayoption.
- Use the new RAD function, jscall(), to call the javascript function from a RAD expression.
There are 2 ways to call a javascript function that resides in ScriptLibrary.
Enter the following in a javascript field:
var tuser="sryburn"; //variables should be declared in javascript
var temail="sryburn@exporttoword.com"; /* literal values can be used in the function call but js didn't like the special char. */
system.library.operatorFunctions.updateEmail(tuser, temail);Documentation says that "library." can be used as a short cut for "system.library." but in my testing "library." by itself was not recognized. When working in javascript fields you must use the "system.library." reference to access a function in a ScriptLibrary record.
Enter the following in a RAD expression array:
$L.user="sryburn";$L.email="test@nowhere.com"
$L.void=jscall("operatorFunctions.updateEmail", $L.user, $L.email)Note that "system.library." is not used in the jscall() function. When I did, I got a signal 11 every time.
jscall() documentation states that arguments are not enclosed in quotes. That is true if you are passing variables or field references (e.g. field in $L.file), but literal strings still have to be enclosed in quotes.