How to Search Attachments by Filename or Extension

Canned Search has introduced support for the Craftware Search Attachments plugin from version 2.0.0. 

Users will be able to search their Jira attachments directly from the dashboard.

This guide demonstrates the steps to add a Canned Search Gadget so that users can search for file containing a particular type in a chosen project

In order for this to work, you need to install the Craftware Search Attachments

How to use it


To search for all attachments in the selected project

To search for all attachments with file name containing workflow in the selected project

To search for all attachments with file name containing workflow and extension pdf in the selected project

To search for all attachments with extension pdf in the selected project

Steps


Setting up the Canned Search Filter

  1. Create a new Canned Filter by selecting Manage Canned Filters under the Issues menu
  2. Click on Add Canned Filter 

  3. Enter the Canned Filter Name and the JQL. For this case, we draft the JQL on the fly

    The following JQL is to select all issues from SCRUM project with attachments "filename.extension". We will convert it to variables later

    project = SCRUM and issue in havingAttachments("name:filename AND type:extension")
  4. Click on Select Variables on the left menu

  5. Click on the top checkbox so that all 3 fields will become variables. You can also click on the individual checkboxes


  6. Change the Type of the project field to dropdown so that the list of projects will appear as a dropdown.
     

  7. Change the Alias for the name:___ to Filename and type:___ to Extension so that it will display Filename and Extension in the search gadget


  8. Change the Type for type:____ to Dropdown. We will also set the Options to ,docx,jpg,pdf,png,xlsx 

    There is a comma before docx because we will to provide a wildcard option for all extensions

  9. Click on Save button to save the filter

Adding the Canned Search Gadget

You can add it in the System Dashboard so that all users can use the feature without having to do the setup themselves.


  1. Click on the Add Gadget link to bring up the Gadget Directory 


  2. Type in Canned to filter the search and click on the Add it Now button to add it to the dashboard


    • Click on the Close link at the bottom right to go back to the dashboard
  3. Configure the Canned Search Gadget by filling in the configuration as below


  4. Click on the Save button

References


Examples

PurposeJQL
To find all pdf attachments in issues from the DOCS project
project = DOCS AND issue in havingAttachments("type:pdf")
To find all png attachments with name containing workflow
issue in havingAttachments("name:lucy AND type:png")

havingAttachments() JQL Function

  • issue in havingAttachments("word") - returns list of issues which have an attachment, which contains a word inside file content;
  • issue in havingAttachments("\"multi-word text\"") - all issues with attachments with a multi-word text in their file contents;
  • issue in havingAttachments("text1 OR text2") - all issues with attachments with either text1 or text2 somewhere in their file contents;
  • issue in havingAttachments("text1 text2") - same as issue in havingAttachments("text1 OR text2") - this is the main difference from Google query syntax - here space means not and but or;
  • issue in havingAttachments("text1 AND text2") - all issues with attachments with both text1 and text2 somewhere in their file contents;
  • issue in havingAttachments("content:text") - same as issue in havingAttachments("text");
  • issue in havingAttachments("type:pdf") - all issues with pdf attachments;
  • issue in havingAttachments("name:workflow OR type:png") - all issues that have attachment with name workflow or with png file extension;
  • issue in havingAttachments("name:summary AND type:txt") - all issues that have attachment with name summary and with txt file extension;
  • issue in havingAttachments("\"search attachment for Jira add-on\" AND name:article01") - all issues that have an attachment containing search attachment for Jira add-on text and the attachment file is named article01 (without the extension);
  • issue in havingAttachments("") or just issue in havingAttachments() - returns list of issues which have at least one attachment (with any contents).

For more info, check out the User Guide for Search Attachment for Jira plugin