Multi line Text Area Character Count (Service Portal Catalog Items) - ajcooper72/ServiceNow GitHub Wiki

This widget provides a character count function for multi-line text fields in the Service Portal. This is similar to the counter available in the backend which can be enabled using the system property glide.ui.textarea.character_counter.

This widget is used in a macro variable and relates to a multi-line text field. The widget can be used multiple times on the same catalog item.

Installation Instructions

  1. Retrieve and import the update set (update_set_textarea_counter.xml) in this repository.
  2. Preview & Commit the update set.

Files when installing this update:

  1. textarea-char-count Widget

Configuration Instructions

On a catalog item, create a new multi-line text field.

Now create a "Custom" variable and set the following values;

  1. On Type specifications tab, set the Widget to "Textarea Character Count".

  2. For the default value enter a JSON value in the following format:

{
	'field-name': 'variable_name_of_text_field',
	'max-chars': 1000
}

The max characters can be omitted and it will default to either 1000 or the value provided in the system property described below.

Additional configuration options are available;

  1. Uses the out of the box message "Characters left: {0}", this ensures that translation is provided by ServiceNow.
  2. A system property can be updated to set the default maximum characters if no value is provided in the JSON; default.multitext.limit
  3. A CSS style can be added to change the appearance of the counter; char-count-text