How to make either of the two fields required on create transition?

Nikhil August 19, 2019

I have two dropdown (select list - Single choice) fields "Internal Group" and "External Group"  which I'd like to add on create screen. As per the project needs, users create tickets for field values of either of 'Internal Group' or 'External Group' field. 

Options for fields:

Internal Group: A, B, C

External Group: 1, 2, 3

Let's say suppose I am creating a ticket for 'Internal Group' - A, I'd like to make 'Internal Group' as a required field and 'External Group' as an optional field and proceed with ticket creation. 

Likewise, If I am creating a ticket for 'External Group' - 1, I'd like to make 'External Group' as required and 'Internal Group' as an optional field. 

 

Can we in Jira add some logic so we can mark both fields as required and automatically make one of them optional based on value selected in other field?

 

Any groovy scripts to achieve this will also be of big help. Thanks!

4 answers

0 votes
Marco Brundel
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 30, 2019

Hi @Nikhil ,

Maybe you can use a Simple scripted validator of Scriptrunner.

And than maybe something like:

cfValues[‘Internal’] != null || cfValues[‘External’] != null 

0 votes
Robert Dzido
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 22, 2019

Hi @Nikhil 

Try using Workflow PowerBox app (if you have Jira on-prem). It has feature called "Validator Templates". you can create a template with 2 validators (one per field) and connect them with "Any of fillowing validators" operator.

Should work:) and you can define your own validation error messages as well.

Unlike ScriptRunners behaviours (great plugin anyway) validators work also when using REST API.

0 votes
jira guy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 19, 2019

You can use script runner behaviors to achieve this. https://scriptrunner.adaptavist.com/latest/jira/behaviours-overview.html

No need to write any scripts if you have already have the plugin

First bullet point in the documentation

  • Making a field mandatory depending on other data entered on the issue screen (i.e during an issue creation or an issue transition)

0 votes
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 19, 2019

I would probably use two different Issuetypes (Internal, External) and have different screen schemes for the two so you could have the appropriate field required.

Another consideration - use a cascading field:

  • Internal
    • A
    • B
    • C
  • External
    • 1
    • 2
    • 3

and make the field required via the create transition validator. 

Suggest an answer

Log in or Sign up to answer