Workflow Transition Condition for attachments and/or links

Robin Knowlton January 19, 2013

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

1 vote
Robert G. Nadon
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.
August 22, 2016

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")}
Robert G. Nadon
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.
August 22, 2016

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

Robert G. Nadon
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.
August 22, 2016

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

Brian W. Bishop March 30, 2017

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

Robert G. Nadon
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.
April 12, 2017

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

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

Chris_Naurois May 23, 2017

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

Cheers :)

roniz December 25, 2017

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")}


  

Robert G. Nadon
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.
December 28, 2017

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")}

Robert G. Nadon
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.
December 28, 2017

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?!?

roniz December 30, 2017

@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"

Robert G. Nadon
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.
January 3, 2018

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

roniz January 3, 2018

thanks! I'll try it out!

0 votes
Timothy
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.
January 19, 2013

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

Robin Knowlton January 24, 2013

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