Breadcrumbs

Attachment MIME types

📚

This template displays the MIME types of the all files attached to the current work item.

If there is nothing to display, the result will be “None”.

Configuration

To use the Attachment MIME types 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?.reduce((result,att) => 
                result.set(att.mimeType,""),
            new Map()).entries().flatten().filter(entry => entry != "")

Details

1. What does the expression do?

This expression collects and lists all the unique MIME types (file types, like "image/png" or "application/pdf") of files attached to the current work item. If there are no attachments, “None” will be displayed.


2. Step-by-step breakdown

Let’s break it down:

  • issue?.attachments?

    • This safely accesses the attachments of the current work item. If there are no attachments, it won’t cause an error.

  • .reduce((result, att) => result.set(att.mimeType, ""), new Map())

    • This loops through all attachments.

    • For each attachment (att), it adds the MIME type (att.mimeType) as a key to a Map (a collection that only keeps unique keys).

    • The value is set to an empty string (the value isn’t important here).

    • The result is a Map containing all unique MIME types from the attachments.

  • .entries()

    • This gets all the key-value pairs from the Map as an array.

  • .flatten()

    • This turns the array of key-value pairs into a simple list.

  • .filter(entry => entry != "")

    • This removes any empty entries from the list.


3. Examples

  • If a work item has three attachments with MIME types: "image/png", "application/pdf", and "image/png", the result will be:

    • "image/png"

    • "application/pdf"
      (Each MIME type appears only once.)

  • If there are no attachments, the result will be displayed as “None”.


4. Real-life use cases

  • Reporting: You want to quickly see what types of files are attached to a work item (e.g., images, PDFs, spreadsheets).

  • Auditing: You need to ensure only certain file types are being uploaded to work items.