Use Case: Verify Attachment Type When Transitioning

Kristin Lyons
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 5, 2021

How to Validate An Attachment is Excel

Tested and Documented in Jira Cloud

What is the Business Need?

Jira allows for any type of attachment to be added to an issue.  If you have an issue type that requires an attachment and the attachment needs to be an Excel file, you will want to use this validator.  One use case is if you have purchase orders that are being created in Excel and you need the purchase order attached to the Jira issue before you can resolve the issue.  

Steps

  1. The attachment field is a standard Jira field and is not one that you have to create.

  2. Ensure the attachment field is on one or more of the following screens: view, edit or transition screen.  Navigate to the Main Menu Bar -> Administration Cog -> Projects

  3. Select the Project where you want to apply this

  4. Click on Project Settings on the left hand menu

  5. On the left hand menu click on Screens

  6. If you have more than one screen scheme, select the issue type where you want to make this change and click on the Create and/or Edit Screen

  7. Add the attachment field

  8. If you would also prefer to have the attachment field show up during the transition, click on the Workflows link on the lefthand menu

  9. Under Actions click on the pencil icon next to the workflow where you want to make this change

  10. For this example, let’s say you want the screen to show up when you are moving the issue from Backlog to In Progress.  Click on that transition.

  11. If there is “None - it will happen instantly” under the Screen section, then click on the Edit button on the upper right hand side of the screen.

  12. Under the Transition View, select the Screen you want to appear in the transition and hit update

  13. Now click on the Screen link and add the Attachment field

  14. Now hit the back button on your browser

  15. Click on the Validators tab in the workflow

  16. Click on Add validator

  17. Select “Build-your-own (scripted) Validator (JMWE app)” and hit add

  18. Add “issue.attachments[0].mimeType.includes(‘application/vnd.openxmlformats-officedocument.spreadsheetml.sheet’)

  19. Under Error message you can add something similar to “Attachment must be Excel” and then click Update

  20. Now Publish Draft

  21. Let’s test it out! 


If you want to validate a different attachment type, you can create a test ticket with the attachment type you want to use. Now use the API to get the attachment information. I used HTTPBot and use this URL: https://<domainname>.atlassian.net/rest/api/3/issue/<issuekey>. On the output, scroll to the bottom and you will see mimeType. That is what you will copy and use in the script.

 

2.png1.png

0 answers

Suggest an answer

Log in or Sign up to answer