Validation in the transition to check ticket has an attachment with file name (RAM) and format

Ravi Kumar Boddu May 9, 2023

Hi All,

Need help to implement transition validation with JIRA MISC WORKFLOW EXTENSIONS

  • Validate whether the ticket has an attachment with the specified file name 
  • Validate the specified file is in excel format.

Please share your thoughts on this how to implement this? Also, https://community.atlassian.com/t5/Jira-Software-questions/Use-Case-Verify-Attachment-Type-When-Transitioning/qaq-p/1631128 I tried this but this is limited to transition screen and this is not working for me :)

Any help would be appreciated and TIA

2 answers

2 accepted

0 votes
Answer accepted
Ravi Kumar Boddu May 11, 2023

Error.JPG

@David Fischer - Please find the error details

0 votes
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 9, 2023

Hi @Ravi Kumar Boddu 

You can use a Build-your-own Validator for this. The Jira expression should be something like:

issue.attachments && issue.attachments.some(att => att.filename.toLowerCase() == "some file.xls" && att.mimeType == "some mime type")

 You'll need to figure out the exact mime type by adding the desired file to an issue and then testing the following expression against that issue: 

issue.attachments[0].mimeType
Ravi Kumar Boddu May 9, 2023

Thanks David for the suggestion , this validation limited to the transition but Is there any away that we can check whether the ticket already has attachment of specific file while doing certain transition.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2023

Hi @Ravi Kumar Boddu 

I'm sorry but I didn't understand your question. Can you please elaborate?

Ravi Kumar Boddu May 10, 2023

@David Fischer - Adding the suggested validation in the transition is limited to the transition screen and it checks whether the specific file (name and format) is attached to the screen or not to move forward with the transition.

However, I want have a additional condition to check whether the file is already attached to the ticket or not then enforce the user to attach the file during the transition if not already present in the attachments else allow the transition.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2023

The code I provided does take existing attachments into account - attachments that were already attached to the issue before the transition started. 

Ravi Kumar Boddu May 10, 2023

Thanks David. I have added below code but still transition is enforcing to attach the document once again though the RiskAssessmentMatrix.xlsx/riskassessmentmatrix.xlsx is already attached to the ticket.

issue.attachments && issue.attachments.some(att => att.filename.toLowerCase() == "RiskAssessmentMatrix.xlsx" && att.mimeType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")

Ravi Kumar Boddu May 10, 2023

@David Fischer - Did you get a chance to review the above? As I mentioned it is not checking the ticket attachements.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 10, 2023

Hi Ravi,

You need to use a lowercase version of the file name to check. Or if you're happy with a case-sensitive comparison, remove ".toLowerCase()" from the script. 

Ravi Kumar Boddu May 10, 2023

Hi @David Fischer - I'm actually using the file name in lower case only  (riskassessmentmatrix.xlsx) but still it is enforcing to attach again.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

Hi @Ravi Kumar Boddu 

can you temporarily replace the validation script with this:

JSON.stringify(issue.attachments)

and then try to transition an issue that already has the required attachment, and post the resulting error message here?

Ravi Kumar Boddu May 11, 2023

Error.JPG

@David Fischer - Please find the error details after performing the transaction with the given script.

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

Sorry, my bad. Can you check this script instead:

JSON.stringify(issue.attachments.map(att => {filename:att.filename, mimeType:att.mimeType}))

and report the error here? 

Ravi Kumar Boddu May 11, 2023

@David Fischer - Below message is showing in the validation screen with the given script. 

[{"filename":"riskassesmentmatrix.xlsx","mimeType":"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"}]

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 11, 2023

Then you need to make sure that your code is checking for exactly that filename and that mime type. 

issue.attachments && issue.attachments.some(att => att.filename.toLowerCase() == "riskassessmentmatrix.xlsx" && att.mimeType == "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
Ravi Kumar Boddu May 11, 2023

@David Fischer -Thank you so much your help here. Its working now.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events