Setting dictionary attributes for all fields in a table or set of tablesIssue <!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Dictionary attributes alter the behavior of the table or element that the dictionary record describes. Administrators can add or modify dictionary attributes. This article provides a JavaScript script that sets a specified attribute across all columns in a table, which helps speed up situations where adding an attribute manually to many tables and fields would otherwise be time-consuming, for example, when disabling text indexing for tables that cannot have it disabled at the collection level because it is inherited from a parent table. Release<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } All releases Resolution<!-- /*NS Branding Styles*/ --> .ns-kb-css-body-editor-container { p { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } span { font-size: 12pt; font-family: Lato; color: var(--now-color--text-primary, #000000); } h2 { font-size: 24pt; font-family: Lato; color: var(--now-color--text-primary, black); } h3 { font-size: 18pt; font-family: Lato; color: var(--now-color--text-primary, black); } h4 { font-size: 14pt; font-family: Lato; color: var(--now-color--text-primary, black); } a { font-size: 12pt; font-family: Lato; color: var(--now-color--link-primary, #00718F); } a:hover { font-size: 12pt; color: var(--now-color--link-primary, #024F69); } a:target { font-size: 12pt; color: var(--now-color--link-primary, #032D42); } a:visited { font-size: 12pt; color: var(--now-color--link-primary, #00718f); } ul { font-size: 12pt; font-family: Lato; } li { font-size: 12pt; font-family: Lato; } img { display: ; max-width: ; width: ; height: ; } } Adding an attribute To add an attribute to a table or field, navigate to the System Dictionary record for the dictionary entry and add the attribute to the Attributes field. Attributes are comma-separated; if a dictionary record already has attributes, add a comma (no spaces) before adding a new attribute. This method can take a while, especially when adding an attribute for many tables and fields. The JavaScript in this article lets you specify the table name and attribute string to set the attribute for all columns in that table. For more information, see Dictionary attributes in ServiceNow product documentation. JavaScript Modify the following variables at the top of the script before running it: •Set vTableName to the name of the target table. •Set vAttribute to the attribute string to apply. •Set vDryRun to true to preview the changes without writing them, then set it to false to apply the changes. 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; } }