Workflow Transition Condition for attachments and/or links

I would like to put a condition on a workflow condition that requires the user to either include an attachment or a link to the issue before they continue. Is this possible?

2 answers

This widget could not be displayed.

I know this is really old but this is the way I did it.  I needed the user to have an attachment called ReadMe.txt so I added the following scripted validator and it works.

Script workflow function : Simple scripted validator : Checks script:

issue.getAttachments().find {it.filename.contains("ReadMe.txt")}

Unfortunately it is case sensitive.  I will have to find a way to .ignoreCase

This did it: issue.getAttachments().find {it.filename.toLowerCase().contains("readme.txt")}

Think there is a way to make that check for a null value on the filename? 

I am sure there is but would have to play.  Right off I would try:

  ! (issue.getAttachments().find {it.filename} )

Robert, thanks for posting this - Did not matter that it was a years old thread, just made my day!

Cheers :)

Hi @Robert G. Nadon,

great post!

I am trying to accomplish validating that there is an attachment with the following naming "PR Form"

I added a validation to the workflow transition but is does not work. any suggestions?

 

-

issue.getAttachments().find {it.filename.contains("PR Form")}


  

First off you need to have the script running plugin.   I would make sure that is bought and enabled.  After that there is a space within "PR Form"  That is not good for filenames.  I would see if you change both filename and query to "PRForm" and see if that works.  Also to avoid case sensitivity maybe try:

issue.getAttachments().find {it.filename.toLowerCase().contains("PRForm")}

Also @Brian W. Bishop I have no idea how to check for a null filename.  How would you even create a file without a filename?!?

@Robert G. Nadon- thanks for the quick replay!

issue.getAttachments().find {it.filename.contains("PR Form")}

worked for me!

another thing-

if i want this validation to work only if another costume field is X can I do it?

For example, this validation should work only if "Animal Type = Dog"

You bet google around and you should find the answer.   That's how I do it :)   I did a quick google and found:

getCustomFieldValue("Severity")

so This would probably work

if ((issue.getAttachments().find {it.filename.contains("PR Form")}) and (getCustomFieldValue("AnimalType") == "Dog") )

 { Do the dog thing }

Or something like that.   You may need the function ToString() as well as I have needed that before.  

Best Luck...

...Robert

thanks! I'll try it out!

This widget could not be displayed.
Timothy Chin Community Champion Jan 19, 2013

Can't seem to find a condition but there is a validator in JIRA Misc Workflow Extensions.

Thanks for the response. We decided to require the links to be a URL custom field, so we could check to make sure that field was not empty. There was also a script condition that allowed to check for 1 or more attachments present befor allowing the transition

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Wednesday in Teamwork

What teamwork quotes inspire you?

Hey everyone! My name is Natalie and I'm an editor of the Atlassian Blog and I've got a question for you: What's your favorite quote about teamwork?  We've compiled a list here, along with...

140 views 16 7
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you