Hi,
I have a custom field called 'Attributes' that is a Multi Checkbox. This has two options currently, 'Ongoing Issue' and 'Review Required'.
I have another customer field 'Reviewer' which is a user picker type.
I want to have a validation on creating an issue that if the 'Review Required' check box is checked then the 'Reviewer' field must have a valid user or at least is not empty.
Currently I have this in the condition field...
cfValues['Attributes'] == 'Review Required' && cfValues['Reviewer'] == null
...this doesn't work though, always seems to evaluate to true as I get the error message I defined.
I also read in another forum that I need to treat the Multi Checkbox differently so I tried...
cfValues['Attributes'][0] == 'Review Required' && cfValues['Reviewer'] == null cfValues['Attributes'][1] == 'Review Required' && cfValues['Reviewer'] == null cfValues['Attributes'][0] == 'Yes' && cfValues['Reviewer'] == null
...all gave the same issues as above.
What am I doing wrong here?
Thanks
Have a look at using power assertions to debug (you need the latest version) - https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-PowerAssertions
There is an example in the section above for multiselects - to see if review required is checked use:
cfValues['Attributes']*.value.contains("Review Required")
Not tested but you probably want something like
cfValues['Attributes']*.value.contains("Review Required") ^ cfValues[
'Reviewer'
]
That means, review required is checked in the field "attributes" exclusive or Reviewer is null.
Thanks for the info...
I tried
cfValues['Attributes']*.value.contains("Review Required") ^ cfValues['Reviewer']
but it never evaluates to true, then I tried this
cfValues['Attributes']*.value.contains("Review Required") ^ cfValues['Reviewer'] == null
It evaluates to true when the checkbox is checked and the reviewer field has a user but not when the reviewer field is empty and the checkbox is NOT checked.
Does the validation evaluate to ok when the condition evaluates to true or false?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If the condition evaluates to true the transition is visible.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So when I use the condition tester I get the following.
assert cfValues['Attributes']*.value.contains("Review Required") ^ cfValues['Reviewer'] == null | | | | | | | | | | | true | | null true | | [Review Required] | [Attributes:[Review Required], Baseline End:null, Baseline Start:null, Budget Bucket:null, Due Time:null, DueTime:null, Epic/Theme:null, Flagged:null, Gantt Options:null, Issue Owner:neivaldocacador:1, Latest End:null, Latest Start:null, Perc. Complete:[0%], Planned End:null, Planned Start:null, Primary Account:J12345, Project Phase:null, Responsible Department:200 - Engineering, Review Results:Required, Reviewer:null, Scratch Pad:null, Secondary Account:Account A, Units:null, Zephyr Teststep:null, issueFunction:null] | [Review Required] false [Attributes:[Review Required], Baseline End:null, Baseline Start:null, Budget Bucket:null, Due Time:null, DueTime:null, Epic/Theme:null, Flagged:null, Gantt Options:null, Issue Owner:neivaldocacador:1, Latest End:null, Latest Start:null, Perc. Complete:[0%], Planned End:null, Planned Start:null, Primary Account:J12345, Project Phase:null, Responsible Department:200 - Engineering, Review Results:Required, Reviewer:null, Scratch Pad:null, Secondary Account:Account A, Units:null, Zephyr Teststep:null, issueFunction:null]
Not to sure how to interpret the results
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So you have two statements: A ^ B. It's saying A and B are true, so A ^ B is false. Which is what you want I think. Ie the multiselect has review required, but the reviewer is null, so just remove the assert and add your error message.
Equally this will be false if there is a reviewer but the checkbox is not selected.
Or possibly you want:
def reviewRequired = cfValues['Attributes']*.value.contains("Review Required") (! reviewRequired) || (reviewRequired && cfValues['Reviewer'])
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This was the final condition
(cfValues['Attributes'] != null && cfValues['Attributes']*.value.contains("Review Required")) ^ cfValues['Reviewer'] == null
My issue was not checking for the null on the 'Attributes', it was causing an exception which mislead me a little.
Thanks Jamie and Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have to use cfValues[...].getValue() to get the value of fields with predefined options.
Henning
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
If you're not sure, you can debug the class name cfValues[] returns.
log.error "returned class: " + cfValues['Attributes'].class.name
and look up the class within the JIRA API.
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.