---
sourceDocument: Australia IT Service Management
sourceDocumentLink: https://www.servicenow.com/docs/r/australia/it-service-management

 Release :

    - australia

ft:locale :

    - en-US

ft:publication_title :

    - Australia IT Service Management

ft:clusterId :

    - itsm

bundleId :

    - itsm

workflow :

    - Technology


---

# Change model attribute API methods

# Change model attribute API methods {#ariaid-title1}

Release version: Australia  
Updated September 30, 2026  
![](https://www.servicenow.com/docs/portal-asset/ico-clock) 3 minutes to read
Summarize  
![AI sparkle icon](https://servicenow.com/docs/portal-asset/ai-sparkle-icon) Summarized using AI  
This content was generated using new OpenAI-powered functionality. Results are provided on an as is basis and are not guaranteed to be accurate or complete.  

## Summary of Change model attribute API methods

This document explains how ServiceNow customers can use server-side and client-side API methods to check and enforce change model attributes on change requests.
These methods enable you to determine whether specific attributes are assigned to a change request's current state or exist anywhere in its change model, allowing you to control behavior dynamically based on the change state.
Show full answer Show less  

## Key Features

* **Server-side methods (ChangeRequest API):**
  * `hasStateAttribute(name)`: Returns true if the specified attribute is assigned to the current state of the change request.
  * `modelContainsAttribute(name)`: Returns true if the attribute exists anywhere in the change model, useful for maintaining backward compatibility when introducing new attributes.
  * These methods can be used in business rules, UI actions, and other server-side scripts to programmatically check attribute presence.
* **Client-side methods (available on the Change Request form in client scripts):**
  * `hasStateAttribute(name)`: Checks if an attribute is assigned to the current state.
  * `containsAttribute(name)`: Checks if an attribute exists anywhere in the model.
  * Accessible via the `changemodel` object on the scratchpad, enabling dynamic UI behavior based on change model attributes.

## Practical Application: Enforcing the Allow CI Modification Attribute

ServiceNow provides a built-in example of enforcing the `allowcimodification` attribute using both client-side and server-side scripts:

* **Client Script:** Makes the Configuration Item (CI) field read-only unless the current change state has the `allowcimodification` attribute. If no state has this attribute, CI remains editable only in the initial state. The script triggers on state changes to keep the form behavior consistent with the change model.
* **Business Rule:** Prevents modifications to the CI field unless the current or previous state has the `allowcimodification` attribute. It preserves original behavior for models without this attribute by allowing CI changes only in the initial state.

This pattern can be adapted to add support for custom change model attributes, helping you enforce attribute-driven rules consistently both client-side and server-side.

## What You Can Expect

* Ability to query and respond to change model attributes programmatically, enhancing control over change request workflows.
* Improved flexibility in managing change request behavior dynamically based on state-specific attributes.
* Built-in examples demonstrate best practices for integrating attribute checks into client scripts and business rules.
* Support for backward compatibility when introducing new attributes by using methods that detect attribute presence anywhere in the model.  
Use these server-side and client-side methods to check which change model attributes are present for a change request in its current state.

## Server-side methods {#change-model-attribute-apis__section_server-side-methods}

The ChangeRequest API provides these methods for use in business rules, UI actions, and other server-side scripts.  
{#change-model-attribute-apis__section_server-side-methods__entry__2}

| Method | Description |
|-|-|
| hasStateAttribute | Returns `true` if the attribute with the specified name is assigned to the current state of the change request. |
| modelContainsAttribute(name) | Returns true if the attribute with the specified name is contained anywhere in the model. Useful when introducing an attribute and you want to preserve existing behavior for models without the attribute. |
[Table 1. ChangeRequest API methods for change model attributes]

## Server-side example {#change-model-attribute-apis__section_server-side-example}

The following example loads a change request and checks its state attributes.

    var changeGr = new GlideRecord("change_request");
    changeGr.get("<sys_id>");

    var changeRequest = new ChangeRequest(changeGr);
    gs.info(changeRequest.getStateAttributes());
    gs.info(changeRequest.hasStateAttribute("allow_ci_modification"));

For a change request in a state that has both attributes, the output includes both attribute names and `true` for each attribute.

## Client-side methods {#change-model-attribute-apis__section_client-side-methods}

A client-side Change Model object is available on the Change Request form for client scripts.  
{#change-model-attribute-apis__section_client-side-methods__entry__2}

| Method | Description |
|-|-|
| hasStateAttribute(name) | Returns true if the attribute with the specified name is assigned to the current state of the change request. |
| containsAttribute(name) | Returns true if the attribute with the specified name is contained anywhere in the model. Useful when introducing an attribute and you want to preserve existing behavior for models without the attribute. |
[Table 2. Change Model methods available on the Change Request form]

The functions can be found in the change_model object on the scratchpad.

## Example: Enforce the Allow CI Modification attribute {#change-model-attribute-apis__section_example-allow-ci-modification}

The base system enforces the Allow CI Modification attribute with a client script and a business rule that use these methods. Together, they keep the original CI modification behavior for models that don't use the attribute and
apply the attribute for models that do. You can follow the same pattern to add support for a custom attribute.

**Client script: Change model: Read only CI**

This client script makes the Configuration item field read-only unless the current state has the Allow CI Modification attribute. If no state in the model has the attribute, the field stays editable in the
initial state only. The script runs when the value of the State field changes, so the form always matches the change model.

    function onChange(control, oldValue, newValue, isLoading, isTemplate) {
        var ALLOW_CI_MODIFICATION = "allow_ci_modification";

        // Retrieve the Change Model API and data from the scratchpad
        if (!g_scratchpad.change_model)
            return;

        var model = g_scratchpad.change_model;

        // Check if the field should be read only based on if the model contains the state and if the "allow_ci_modification" attribute has been added to the state
        var isReadOnly = model.containsAttribute(ALLOW_CI_MODIFICATION) ?
                !model.hasStateAttribute(ALLOW_CI_MODIFICATION) : g_form.getValue(model.field) + "" !== model.initial_state;

        g_form.setReadOnly("cmdb_ci", isReadOnly);
    }

**Business rule: Change Model: Read only CI**

This business rule prevents changes to the configuration item on a change request unless the current or previous state has the Allow CI Modification attribute. If no state in the model has the attribute, the configuration item can
still change in the initial state. The business rule runs when the configuration item changes on a change request that has a change model.

    (function executeRule(current, previous /*null when async*/) {
        var ALLOW_CI_MODIFICATION = "allow_ci_modification";

        var changeRequest = new ChangeRequest(current);
        var preChangeRequest = new ChangeRequest(previous);
        var modelContainsAttribute = changeRequest.modelContainsAttribute(ALLOW_CI_MODIFICATION);

        // If the attribute isn't enabled preserve original 'initial state' CI changes
        if (!modelContainsAttribute && (changeRequest.isInitialState() || prevChangeRequest.isInitialState()))
            return;

        // If the current state has the attribute allow the CI to be modified
        if (changeRequest.hasStateAttribute(ALLOW_CI_MODIFICATION))
            return;

        // If the previous state has the attribute also allow the CI to be modified
        if (new ChangeRequest(previous).hasStateAttribute(ALLOW_CI_MODIFICATION))
            return;

        // Otherwise, if it's a new record (no previous record) use the model to lookup the attribute on the intial state
        var changeModel = new ChangeModel(new ChangeRequest(current).getModel());
        if (current.isNewRecord() && changeModel.hasStateAttribute(changeRequest.getInitialState(), ALLOW_CI_MODIFICATION))
            return;

        // Abort the modification
        gs.addErrorMessage(gs.getMessage("Configuration item cannot change for Change Requests in this state"));
        current.setAbortAction(true);
    })(current, previous);


