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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This did it: issue.getAttachments().find {it.filename.toLowerCase().contains("readme.txt")}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Think there is a way to make that check for a null value on the filename?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am sure there is but would have to play. Right off I would try:
! (issue.getAttachments().find {it.filename} )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Robert, thanks for posting this - Did not matter that it was a years old thread, just made my day!
Cheers :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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")}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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")}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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?!?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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 must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can't seem to find a condition but there is a validator in JIRA Misc Workflow Extensions.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.