How to force user to attach files while creating JIRA

Pushpkant Garg June 29, 2016

I know how to make Attachment field mandatory but I want users to attach atleast 3 files to JIRA ticket while creating an issue.

 

Any one can please help me how can I do the same?

 

2 answers

0 votes
Sten Sundelin
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.
June 30, 2016

Can you add the validator on the next transition(s) in the workflow or write a postfunction that flags the issue and/or emails the creator somehow?

This would allow the creation of the issue, but prevent it from being acted upon further unless/until you have your three attachments.

I know it's not an exact solution, but maybe a possible workaround?

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 29, 2016

You'll need to find or write a validator add-on that can check the number of attachments.

It's a doddle if you've got something like the Script Runner add-on.

Pushpkant Garg June 29, 2016

Hello Nic,

I tried below option. Still not working.

Add Validator –> Script Validator --> Simple Script --> Has one or more attachments

attachmentManager.getAttachments(issue).size() >= 3

I added three attachments, still JIRA is not allowing me to create issue.

I also tried other option, to have atleast one Pdf

attachmentManager.getAttachments(issue).any{it.filename.endsWith('.pdf')}

JIRA is not allowing me to create issue in this case also. 

Can you please help me in this?

Thanks,

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 29, 2016

I don't think it's as simple as that.

At the point that the validator runs on "create", the issue has not been created, so your code is fetching a 0 as it's not there. 

I'm not sure, off the top of my head, how to deal with that.

Tóth_Roland_Richárd October 29, 2019
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 29, 2019

Not changed, I've not found a reason to look for this, so I've not found any code that might do it.

Suggest an answer

Log in or Sign up to answer