HELP!

General JavaScript Examples

Writing Conditional Code (if/else command)

if (#Grade.val() == "Director") {
  #Department.val("Boardroom");
  xpertrule.message("Boardroom location");
} else if (#Grade.val() == "Senior Manager") {
  #Department.val("Management");
  xpertrule.message("Management office");
} else {
  #Department.val("Office");
  xpertrule.message("General office");
} 
The above example is to illustrate JavaScript syntax of if/else only. Any "Business logic" (such as those shown in this example) should be implemented using Knowledge Objects (such as Decision Trees) rather than hard coded inside Scripts

Using Looping

var loop;
for (loop = 1; loop <= 10; loop = loop + 1) {
  #strArr.val()[loop] = "Empty";
} 

Alternatively

for (var loop = 1; loop <= 10; loop++)
  #strArr.val()[loop] = "Empty"; 
If there is only a single command in the command block, the braces {} are not required.
To increment a number, you can use the ++ syntax and use -- for decrementing it.

On This Page