Wizard scripts

You can create scripts to implement advanced custom functionality using wizards.

Use wizard scripts in record generator panels, transitions, and UI policies.

Note: The System Wizards application is not active by default.

To reference a wizard variable in a script, use the format wizard.<name>, where <name> is the value in the Name field of the variable definition.

Wizard script examples

These examples demonstrate scripts that use wizard variables.

Example 1

//Find a user in the sys_user table with the wizard variable 'EmpName'
function getUser(){
     var gu = new GlideRecord('sys_user');
     gu.addQuery('sys_id',wizard.EmpName);
     gu.query();
     if(gu.next()){
         gs.addInfoMessage('Found user ' + gu.name)
     }
}

Example 2

//Loop through items in a wizard list collector with variable name astList 
function removeAssets() { 
     var items = wizard.astList.toString();
     items = items.split(','); 
         for (var i =0; i < items.length; i++) { 
             //got the asset id 
             var sys_id = items[i]; 
         } 
}

Example 3

//Set the url on wizard completion - user will be redirected to this location
var uri = ('sys_user_list.do?sysparm_query=sys_id=' + wizard.EmpName);
wizard.redirect = uri;

Wizard scripts on record generators

Use wizard scripts in record generator panels to create records in any table, including on more than one table.

  1. In the Table field, select Global.
  2. Enter a script in the Script field. Configure the form to add the field, if necessary.
    Record generator script

Wizard UI policy and client scripts

Administrators and users with appropriate access rights can create dynamic effects for wizards using UI policies and client scripts, including:

  • Get or set variable values
  • Hide or display variables
  • Make variables mandatory
  • Validate form submission
UI policies apply effects based on conditions constructed with a condition builder. Client scripts accomplish more advanced functionality. Because UI policies do not require scripting, they are less likely to need maintenance after system updates.
Note: The System Wizards application is not active by default.