Forums

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

Fields required based on other custom field values

siva
Contributor
December 1, 2022

Hello there,

We are using three fields in the create screen and they are

Upgrade (single select single choice), values are None, Yes, No, SC and ST ("customfield_1112")

Base version (text field single line) ("customfield_113")and

Final version (text field single line)  ("customfield_114")

When the Upgrade value is other than None, I need the Base version and Final version fields to be filled in. If the Upgrade value is None, there is no need for the required field. Please assist me with this; I'm new to scripts and your assistance is greatly appreciated. Please let me know if you need any information on this.

Note: We are using the Scrip runner  plugin in my server instance and help me how to solve this issue.

 

Thanks,

Siv.

1 answer

1 accepted

2 votes
Answer accepted
Fazila Ashraf
Community Champion
December 1, 2022

Hi @siva 

Check out the answer in https://community.atlassian.com/t5/Adaptavist-questions/ScriptRunner-behaviour-for-hiding-a-field-based-on-another/qaq-p/1755119 and use 

.setRequired(true)   

 as required for your use case.

 

Trying scripting as a newbie could be daunting.. But trust me, once you are able to understand the given script and modify it for your use case, it opens many doors :) 

Vikrant Yadav
Community Champion
December 4, 2022

Hi @siva  Kindly try to apply Behaviour on Upgrade field. 

As suggest by @Fazila Ashraf  , you only need to replace .setHidden with .setRequired

def dropDown = getFieldById("customfield_12345")//Change field ID as per your instance

//define base version field
def baseVersion = getFieldById("customfield_67891") //Change field ID as per your instance

//define Final Version field
def finalVersion = getFieldById("customfield_66666") //Change field ID as per your instance

//apply condition on select list field

if(dropDown.getValue()== "None"){
baseVersion.setRequired(true)
finalVersion.setRequired(true)
} else {
baseVersion.setRequired(false)
finalVersion.setRequired(false)
}

Suggest an answer

Log in or Sign up to answer