How to set checkbox options mandatory depending on another field value?

Li Huang May 17, 2016

Hi everybody,

Is it possible to set multiple options mandatory in a checkbox field depending on another field value?

For example, I have a checkbox field and a select list field

Select list field has the following options. Only one option can be selected.

  • A
  • B
  • C
  • D
  • E

Checkbox field has the following options. Multiple options can be selected.

  • F
  • G
  • H
  • I
  • J
  • K
  • M

If "B" is selected from select list field, can we put H, I, J, K as mandatory options when JIRA workflow transits to another status?

I'll appreciate if you have any suggestions.

 

 

2 answers

0 votes
WendyA May 18, 2016

Well, when I said 'custom' validator, I mean one our team wrote 'from scratch'.  Not a huge deal, just...:

Velocity templates (edit, input, view),

2 Java classes (one that implements com.opensymphony.workflow.Validator and the other extends AbstractWorkflowPluginFactory and implements WorkflowPluginValidatorFactory, both from the com.atlassian.jira.plugin.workflow package), 

and an atlassian-plugin.xml file (not 'in a pear tree...' ;-} LOL) 

Some 'MyXyzValidator' holds a CustomFieldManager variable (passed into constructor) to get contents of custom fields, but the conditional logic is in the 'validate' method, wherein you can structure tests on whatever values you want, and if the test(s) fail(s), you throw an InvalidInputException (containing any error message you want to show the user).  The plugin XML file must specify the validator class and templates, and the plugin must be compiled/packaged, and then installed by the JIRA administrator. THEN the custom validator must be added to a workflow transition to execute.

There are tutorials that do a much better, more complete job of explaining this (I don't have the URL handy, but they are easy to find), so good luck!

 

 

0 votes
WendyA May 18, 2016

I'm new to JIRA development, but in the past, the developers of my current project did something similar to this using a custom 'validator' plug-in, which was added to any workflow transitions on which it should be enforced.  I'm not sure if this is the best (or only?) approach, but it did work.  Note: this won't mark the field as 'mandatory' (with *), but does cause the transition to fail, and gives the user whatever custom feedback you want...

Li Huang May 18, 2016

Hi Wendy,

Thanks. We are using the workflow validator plugin that can cause transition to fail based on predefined condition/validator. Do you know what condition/script should be configured to implement the example use case I described?

 

Suggest an answer

Log in or Sign up to answer