Format Control

The following example can be used to verify whether or not the operator who was just entered in the assignee.name field in an incident record is currently logged in. Otherwise, validation will fail.

  1. In the Calculations section of Format Control, enter a condition of true in the initial column. Then add the following codes in the calculation column.

    $assignee.old = nullsub(assignee.name in $file, “no assignee”)
  2. Click the JavaScript tab, enter true for Add and Update, and then enter the following statements.

    var usersXML = system.users;
    var usersString = usersXML.toXMLString();
    var file = system.vars.$file;
    var newAssignee = file.assignee_name;
    system.vars.$IsUser=usersString.indexOf(newAssignee);
  3. In the Validation section, enter the following codes in the Add and Update column respectively.

    assignee.name in $file~=$assignee.old;
  4. And the following expression in the Validation column.

    $IsUser > 0
  5. Enter the following in the Validation message field.

    The new assignee is not logged in at this time. Please try another assignee.

This example uses the standard indexOf method for the String Object, and the toXMLString() function, to search for the user who was entered as the new assignee in the XML object containing all logged-in users.

Any RAD variable can be set and used by preceding it with system.vars. This lets variable values be exchanged between JavaScript and RAD expressions.