I have a simple scripted validator I want to validate whether a field it filled out based on another field's value:
cfValues['Implementation Method']?.getValue() == "Premise" || cfValues['Implementation Method']?.getValue() != "Premise" && issue.projectObject.key != "ELM"
When "Premise" is the value in the custom field it lets me move the workflow. When "Premise" is not the value, it throws a validator against Due Date (as intended), but keep throwing it even after I fill out Due Date field.
Also, I need this to be expanded to 3 other projects, and wasn't positive on how to do that.
Thanks in advanced.
Use the condition tester with asserts, that should make it clear.
There's nothing wrong with the script. Even testing against a simple line I'm having the same issue: the script throws the validation error against the Due Date field, but keeps throwing it even after I fill out due date. If I use a different custom field, it works how I expect it to. Both custom fields are of Select List type.
I don't understand where Due Date comes in to this. Can you attach a screenshot?
If you've put the error against Due Date it will go against that field, but if that field is not in the validator it has nothing to do with whether the condition passes.
Is your objective to make the due date required depending on some other conditions?
If so you should do
cfValues['Due Date'] || ! (your current clause)
that is, the due date is required unless your current clause is true.
Due Date is not a custom field, but a system field, would cfvalues['Due Date'] still work for system field? I did put it against the field without the field in the validator, and I have done so in the past and it worked fine. The current one also works the same way with a different custom field then I am using currently.
Ok, I figured it out, I just needed to replace cfvalues['Due Date'] with issue.getDueDate() != null and it seems to work.
Is there any way to adjust the issue.projectObject.key != "ABC" to multiple project keys or do I need to use || and brackets for each different key? I need to to do it for 4 projects
To be honest: I'm not an expert (more a noob) in this.
Just having some experience with it, cause I had to do something and also had to experiment ...
-Correct cf name?
-Try using the cf-id?
-Test with the println ?
Jamie Echlin is an expert in this mather, try adding tags with his name, so he will notice this question? :)
We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...
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!
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