validating multi check box custom field using script runner plugin

Hi,

I have a multi check box custom field 'DOD' , which has options/items as start,stop,resolve.

Now what i want to implement is whenever a user tries to close a issue he should have atleast ticked start in custom field, if he has done so he will be able to close issue else he wont.

For this i am using script runner plugin and implemented a workflow validator on close issue as 'simple scripted validator' .

The condition in this simple scripted validator i have put is show below

cfValues[DOD] == 'start'

However this doesnt seems to work and although if the user ticks the 'start' in customfiled DOD he is not able to close issue.

Can someone please help me?

Regards,

Akhil

4 answers

1 accepted

cfValues['DOD']*.value.contains("start")

try something like above code

Thanks .... that worked

But if i want to check all options then below command doesnt work ...Any idea

cfValues['DOD']*.value.contains("start","stop","resolve")

cfValues['DOD']*.value in ['start', 'stop', 'resolve']

This also doesnt work for me .... i still see errors in log

2014-03-20 10:24:19,074 http-bio-8080-exec-19 ERROR admin 624x502x1 kffx3j 127.0.0.1 /secure/CommentAssignIssue.jspa [atlassian.jira.workflow.OSWorkflowManager] Caught exception while attempting to perform action 2 from workflow 10300 on issue 'COR-1'

[InvalidInputException: [Error map: [{}]] [Error list: [[error 101]]]

In condition tester run:

cfValues['DOD'].value*.value.contains("start")

and provide the output here. I didn't really read your question properly - you just want to ensure that at least "start" is checked? If so I think the above should do it.

Hi Jamie,

I want to check that all three options(start,stop,resolve) of the DOD custom field should be checked, and only if all 3 options are present then only the transition would happen else it should fail

How do I say does not contain?

! cfValues['DOD'].value*.value.contains("start")

Hi jamie,

Below is the output from condition tester on an issue

javax.script.ScriptException: groovy.lang.MissingPropertyException: No such property: value for class: Script1

Hi Jamie,

Below is the output of cfValues['DOD']*.value in ['start', 'stop', 'resolve'] in condition tester.

see attached screenshot below for TICK-5 in which i have checked all 3 options, so as per my understanding the result should evaluate to true but thats not the case.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas 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...

86 views 0 5
Read article

Atlassian User Groups

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!

Find my local user group

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

Groups near you