It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
I have a workflow validator on the Create transition of one of my workflows that looks like this:
cfValues.get("Module / Subprocess")?.keySet()?.size() == 2
This field is a cascading select field and we want both dropdowns within that field to be required. As far as I know, when you make this field required in the field configuration, only the first dropdown is actually required. We need both filled out, which is the reason for the scripted validator on the Create transition.
This scripted validator works correctly - however, all of our projects use this field except ONE project, even though all projects use the same issue type on which this field applies. We only have one workflow for this issue type so we don't have to manage tons of workflows for every project, so we'd really like to avoid creating a separate workflow just to not have this validator on one project. Our team of JIRA admins isn't very big, so we try to keep everything we need to manage to a minimum as much as possible.
So, for my question - is it possible to create a scripted workflow validator that checks if this field has the current project within one of its contexts? If yes, then it will check the validator written above.
Probably, but I suspect it will be much easier to just check against the one project that doesn't have it, by name.
Alternately, you could check the count of the first half of the cascading field; since it is mandatory, it being zero/null/whatever, should be sufficient to indicate that you don't need to validate the second half.
Hi, Jeremy and Jamie - thanks for your input. I'd like to go forward with the option to check the project key, but I can't seem to get that working. I've added the statement to what Jamie put and it looks like this now: issue.projectObject.key == "ABC" || cfValues.get("Module / Subprocess")?.keySet()?.size() == 2 We're using the correct project key in place of ABC, but it doesn't work correctly. It prevents the projects that do use this field from creating the issue (i.e. the validator returns as false). If I remove the new statement, the query works for the other projects as it did before. I also tried this variation (apologies - my groovy knowledge isn't great): issue.getProjectObject().getKey() == "ABC" || cfValues.get("Module / Subprocess")?.keySet()?.size() == 2 Anything I might be missing here? Thanks again for your help.
It looks okay, but I've been trying to make it work here with no luck... I can't even get the basic project key check to work. It may be that the issue doesn't have a project object yet, in which case I've read of alternate ways of validating it, but maybe my other idea is simpler. If you make the field mandatory for the projects that have it, then you could use: cfValues.get("Module / Subprocess")?.keySet()?.size() == 2 || cfValues.get("Module / Subprocess")?.keySet()?.size() == 0 If we get past this validation for the 0 case, the field being mandatory will still kick in where relevant. Mind you, I'm assuming we'll get '0' if the field isn't defined, I haven't tested this one either.
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreAtlas Camp is our developer event which will take place in Barcelona, Spain from the 6th -7th of September . This is a great opportunity to meet other developers and get n...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.