Thank you for your feedback.
Form temporarily unavailable. Please try again or contact to submit your comments.

Create or edit a planned change validation script

Log in to subscribe to topics and get notified when content changes.

Create or edit a planned change validation script

Create a custom script that checks if a change to a class was valid according to business requirements, and whether the change was planned or not. A planned change validation script is used whenever a CI change is viewed in the CI timeline or change history.

Before you begin

Role required: admin or itil

About this task

The system attempts to validate each CI change as follows:

  • If a custom script exists for the CI or one of the CI parents, then the script is executed and the results are used to flag the change as valid or invalid. Parent CIs are examined in the hierarchical order.
  • If a custom script does not exist for the CI or any of its parents, then a predefined validation script is used. The change is determined as a planned change if the change occurred between the Work start and Work end dates of the change request associated with the changed CI.

    However, this check is not always reliable because a user might have manually modified the CI within the work dates, which flags the change as valid even if it is invalid.

The script needs to return a boolean, true or false, which depends on meeting the test criteria in the script. You can define a separate script for each CI class, and you can define multiple planned change validation scripts for a single class. For example, to maintain different versions of the script. Only one script can be active for a CI class at any given time.

These are the parameters that uniquely characterize a change:

  • The fields that were changed
  • The data source that performed the change
  • The time stamp of the change

To correctly determine the validity of a change, examine all of these parameters and apply business logic to evaluate if the validation tests are met. A planned change validation script can test any of these characteristics and determine if a change meets pre-established criteria. For example, the custom script can check if the mode of the CI is operational or maintenance, or who initiated the change.


  1. Navigate to Configuration > Change Verification > Planned Change Validation Script.
  2. Click New or select a validation script to edit.
  3. Complete the form.
    Table 1. Planned change validation script form
    Control Description
    Active Check box to activate this script for validating changes.
    Applies to Class that this script applies to.
    Script Script to run to validate a change. If the script does not return a boolean value, then it is configured to false.
    The script has a template which displays the input variables of the script.
    Table 2. Template script input variables
    Variable Type Description
    current GlideRecord Current record that is being processed.
    updatedOn GlideDateTime Time stamp of the change.
    updatedBy String Entity responsible for the change.
    fieldsChanged String Comma-separated list of the names of all fields that were changed.
    This sample script checks who initiated the record update. It returns true if admin initiated the record update. Otherwise, the script returns false.
    function isValidChange(/*GlideRecord current, GlideDateTime updatedOn, String updatedBy, String changedFields*/) 
       //Return true if the user that updated the record has an admin role 
       return isUserAdmin(updatedBy); 
    function isUserAdmin(userName)
       var grUser = new GlideRecord("sys_user");
       grUser.addQuery('name', userName);
           var roles = new GlideRecord ("sys_user_has_role");
           roles.addQuery('user', grUser.sys_id);
              if( == 'admin')
                 return true;
       return false;
  4. Click Submit.