Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Custom field required based on other custom field.

Ash
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.
March 8, 2019

Hi Team,

We have two custom fields in a projects.

 

Custom Field 1 is single line text type

Custom Field 2 is date type

 

Now here is the requirement, If data entered in CF1 the CF2 should be a mandatory field.

If CF1 has nothing in it then CF2 is not mandatory. Can we do this while creating and editing issues?

Appreciate if someone has a sample code using Scriptrunner/ behavior.

 

JIRA version 7.12.3

TIA!!

 

1 answer

0 votes
Carmen Creswell [Adaptavist]
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.
March 14, 2019

Hi Ash, 

This script should work for you. You'll just need to change the names of your custom fields. This goes in a Behaviour on the Single Line Text Field. 

def singleText = getFieldByName("TextFieldA")
def dateField = getFieldByName("First DateTime")

if (singleText.getValue() == "") {
dateField.setRequired(true)
} else {
dateField.setRequired(false)
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events