Breadcrumbs

Number of characters in a field

📚

Return the number of characters in any text field including spaces.

Configuration

Create a Custom smart number field and use the General parsing mode.

Expression

%{count(findPattern(%{issue.cfnnnn}, "."))}

Please, note that it is necessary to replace nnnnn with the ID of the custom field containing the URL.

Display as

Number

Formatting style

Custom format

Pattern

#,##0.##

Used parser functions

:note:

The links lead to the JWTC documentation because the parser functions are shared functionalities.

Details

1. What does the expression do?

The expression counts the total number of characters (including spaces) in a specified text field of a work item.

2. Step-by-step breakdown

Let’s break it down:

  • %{issue.cfnnnn}: This retrieves the value of a specific custom field from the work item. You need to replace nnnn with the actual ID of your custom field (for example, 12345).

  • findPattern(..., "."): This function searches the field's text for every single character. The dot (".") is a pattern that matches any character, including spaces.

  • count(...): This function counts how many matches were found by findPattern, which is effectively the number of characters in the field.

3. Examples

  • If the field contains the text: Hello world!

    • findPattern will match each character: H, e, l, l, o, (space), w, o, r, l, d, !

    • count will return 12, because there are 12 characters including the space and punctuation.

  • If you want to count the characters in the work item description, you would use:

    %{count(findPattern(%{issue.description}, "."))}
    

4. Real-life use cases

  • Social media preparation: If you need to ensure your work item descriptions or custom fields do not exceed a certain character limit (for example, X posts), this expression helps you track the character count directly in Jira.

  • Quality control: Enforce or monitor minimum or maximum text lengths in custom fields for consistency or compliance.

  • Reporting: Generate reports or dashboards showing the length of text fields across multiple work items.

    image-20250916-111217.png