How to validate the number of attachments on a screen in jira5.0.5

S October 21, 2012

Currently, I am using TemporaryAttachment API to get the number of attachments on a screen. The problem however is that when someone attaches a file on jira screen and unchecks the check box to the left of it, there is a file in temporary attachments collection but no file is attached to the issue. Effectively, this practice can bypass my validator. Is there any possible way to make a fullproof validation.

3 answers

1 accepted

0 votes
Answer accepted
Radu Dumitriu
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.
October 21, 2012
S October 21, 2012

Thanks, works perfectly for me.

Map<String, ModifiedValue> modifiedValueMap = mIssue.getModifiedFields();

ModifiedValue modifiedAttachmentValue = modifiedValueMap.get("attachment");

List<String> modifiedAttachmentList = (List<String>) modifiedAttachmentValue.getNewValue();

if(modifiedAttachmentList.size()>0)

{

//success

}

Radu Dumitriu
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.
October 21, 2012

Glad to be of any help.

Development August 16, 2016

Hello All, 

Kindly help me for this problem, i am not able to get screen attachment name ..............

 

 

0 votes
S November 27, 2013

Hi Dolanbay,

I have posted the code which worked for me below Radu's links. You can add the validator at create step for your requirement. Adding the validator at create will not allow anyone to create an issue without attachment.

Regards,

Smruti

0 votes
Özerk Dolanbay November 26, 2013

Hi Smruti,

The links Radu shared doesn't work so could you paste the code you wrote?

One more favour, I also try to use a validator which checks whether an attachement is uploaded or not while creating an issue. I mean I don't want users to create an issue without an attachment.

Suggest an answer

Log in or Sign up to answer