Breadcrumbs

Count attachment authors

πŸ“š

This template displays the number of users who added an attachment to the current work item. Each user is only counted once.

Configuration

To use the Count attachment authors template, simply select it from the template grid. Filter by Attachment to find it faster.

Parameters

This template does not require any additional parameter configuration.

Expert mode

If you switch to Expert mode you can see the formula field in the Expression Parser. You can now tweak the expression to create a custom formula field based on this template.

Expression

Jira expression:

issue.attachments.map(attachment => attachment.author.accountId).reduce((a, b) => a.includes(b) ? a : a.concat(b), []).length

Display as

Number

Formatting style

Default (unformatted)

Details

1. What does the expression do?

This expression calculates the number of unique users who have added attachments to a specific work item. Each user is counted only once, no matter how many attachments they have added.


2. Step-by-step breakdown

Let's break it down:

  • issue.attachments: This retrieves the list of all attachments on the current work item.

  • .map(attachment => attachment.author.accountId): This goes through each attachment and extracts the account ID of the user who added it, creating a list of all authors' account IDs (including duplicates if a user added multiple attachments).

  • .reduce((a, b) => a.includes(b) ? a : a.concat(b), []): This step removes duplicates from the list of account IDs:

    • It starts with an empty list ([]).

    • For each account ID (b), it checks if it is already in the list (a.includes(b)).

    • If it is already included, it leaves the list unchanged.

    • If it is not included, it adds (concat) the account ID to the list.

  • .length: Finally, this counts how many unique account IDs are in the list, which equals the number of unique users who have added attachments.


3. Examples

Suppose a work item has three attachments:

  • Attachment 1 added by User A

  • Attachment 2 added by User B

  • Attachment 3 added by User A

The steps would be:

  • Extract account IDs: [A, B, A]

  • Remove duplicates: [A, B]

  • Count: 2

So, the result would be 2 (since two unique users added attachments).


4. Real-life use cases

  • Audit and reporting: Quickly see how many different team members have contributed files to a work item.

  • Collaboration tracking: Identify work items with broad team involvement based on attachment activity.

  • Quality control: Spot work items where only one person is uploading files, which might indicate a lack of collaboration.