Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
How to set dictionary attributes quickly for all fields in a table or set of tables - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • How to set dictionary attributes quickly for all fields in a table or set of tables
KB0661882

How to set dictionary attributes quickly for all fields in a table or set of tables


7049 Views Last updated : Jul 24, 2025 public Copy Permalink English (Original)
  • English (Original)
  • Japanese
KB Summary by Now Assist

Issue

Dictionary attributes alter the behavior of the table or element that the dictionary record describes. Administrators can add or modify dictionary attributes.

Adding an Attribute

To add an attribute to a table or field, you generally navigate to the System Dictionary record for the Dictionary entry and add the attribute to the Attributes field. Attributes are comma-separated; if attributes already exist on a dictionary record, add a comma, with no spaces, before adding a new attribute.

This method can take a while, especially if you're adding an attribute for many tables and many fields.  The JavaScript provided in this article enables you to specify the table name and the attribute string and set the attribute for all columns in that table. This should help speed up situations where you want to disable text indexing for tables but cannot disable it at the collection level because it's inherited from a parent table.

For more information, see the product documentation topic Dictionary attributes.

JavaScript

var vTableName = 'cmdb_ci_printer';
var vAttribute = 'no_text_index=true';
var vDryRun = false; // set this to false when you're ready to do the change
 
// Do Not Modify below this line
 
bulkUpdateTableAttributes(vTableName, vAttribute, vDryRun);
 
function bulkUpdateTableAttributes(pTableName, pAttribute, pDryRun) {
    var gr = new GlideRecord('sys_dictionary');
    gr.addEncodedQuery('name=' + pTableName + '^element!=NULL');
    gr.query();
    var bUpdate = false;
    while (gr.next()) {
        var vAttributes = gr.attributes;
        var nLength;
        if (vAttributes) {
            nLength = vAttributes.length;
        } else {
            nLength = 0;
        }
        if (0 == nLength) {
            // There are no other attributes, just set it
            gr.attributes = pAttribute;
            bUpdate = true;
        } else {
            // Attributes is not empty, check to see if we have it set already:
            var n = vAttributes.indexOf(pAttribute);
            if (-1 == n) {
                // The attribute is not set, so append it:
                gr.attributes = vAttributes + ',' + pAttribute;
                bUpdate = true;
            } else {
                // The attribute is set; do nothing
            }
        }
        if (!pDryRun) {
            if (bUpdate) {
                gs.print('Updating record sys_dictionary.do?sys_id=' + gr.sys_id + ' to ' + gr.attributes);
                gr.setWorkflow(false);
                gr.update();
            }
        }
        bUpdate = false;
    }
}

The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.