Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Behaviours Plugin - Making a field mandatory depending on other data entered in to the form

AndreH
Contributor
March 20, 2013

I have a custom field in Jira and it is a drop down (Yes, No)

Now based upon the answer of this custom field, if Yes, then make another custom field (text unlimited) required.

custom field - Fiance Change (Yes, No)

custom field - Finance Approval (free form text field unlimited)

How do I make the Finance Approval custom field required if the drop down value of Finance Change is set to Yes?

I don't have any scripting knowledge and I don't see an easy way to create this behaviour.

1 answer

0 votes
JamieA
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 20, 2013

Add this script to the finance change field, apply behaviour to project:

def finCf = getFieldByName("Finance Change")
def appCf = getFieldByName("Finance Approval")

appCf.setRequired(finCf.getValue() == "Yes")

leoz
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 6, 2013

Hi Jamie,

The mandatory field in my side is JIRA System field "Linked Issues", I tried your script but it doesn't work, do you have any idea? Thanks

def A = getFieldByName("Root Cause")
def B = getFieldByName("Linked Issues")
 
B.setRequired(A.getValue() == "Caused by Defect Fix")


					
				
			
			
			
				
			
			
			
			
			
			
		
Hernan Montes
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.
May 3, 2014

I have the same issue!!, please help

Guy Anela
Contributor
June 4, 2014

Hi Jamie - I'm using the solution you provided above, BUT I'm seeing something that I'm assuming is a bug. All initially seems to work fine except when I delete the contents of the field that's required it makes the field required when it shouldn't be (See Use Case below).

I'm hoping you have a solution on how to workaround it.

USE CASE:

I have these two custom fields created...

  1. Issue Blocked (A Select List field with Yes/No values)
  2. Reason Blocked (A Text Field)

The following script is associated with the Issue Blocked field...

def blockedCf = getFieldByName("Issue Blocked")
def reasonCf = getFieldByName("Reason Blocked") 

reasonCf.setRequired(blockedCf.getValue() == "Yes")

Steps to reproduce the issue:

  1. Load the Issue Create screen (or Edit screen).
  2. Outcome: The "Issue Blocked" field is set to "None" by default and the "Reason Blocked" field is NOT required (which is correct).
  3. Set the "Issue Blocked" field to "Yes".
  4. Outcome: The "Reason Blocked" field is now required (which is correct).
  5. Input some text into the "Reason Blocked" field.
  6. Outcome: The "Reason Blocked" field remains required (which is correct).
  7. Set the "Issue Blocked" field to "No" (or "None").
  8. Outcome: The "Reason Blocked" field is no longer required (which is correct).
  9. Delete all of the text that was entered into the "Reason Blocked" field.
  10. Outcome: The "Reason Blocked" field is now required (which is NOT correct.... because the "Issue Blocked" field is still set to "No".
Has this issue been reported before? Do you know of a workaround?
Thanks in advance!
Guy Anela
Contributor
June 4, 2014

I entered JBHV-294 for this issue. It contains screenshots for further clarification on the behavior I'm seeing. Cheers!

JamieA
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.
June 5, 2014

OK, I'll have a look... cheers for the issue, the screenshot is very clear.

Guy Anela
Contributor
June 5, 2014

Perfect! Hope to hear from you soon. ...thanks again Jamie!

Kathryn Allison
Contributor
January 23, 2015

Along the lines of the original request....I need to do the following: system field - fixVersion custom field - Detected in Version (single version picker) custom field - Reason for Deferral (multi-select list) How do I mandate Reason for Deferral custom field if fixVersion does not match Detected in Version? Null value should be excluded from the mandate.

Kathryn Allison
Contributor
January 31, 2015

Does something need to be different if the cf is a scripted field? I am using following, where "Version Control" is a scripted CF that can contain "Deferred" or "In Scope" as values...this doesn't do anything. def versionCf = getFieldByName("Version Control") def reasonCf = getFieldByName("Reason for Deferral") reasonCf.setRequired(versionCf.getValue() == "Deferred")

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events