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');
         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;