Forums

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

Validation script for check box

Srikanth Gogineni August 8, 2018

Hi All,

Need validation script for check box, here is the scenario,

i have a check box field which has only one option (yes) , when i checked Yes the dependent field is of Multi Select should be required .

 

i have used below code , could you help to correct it 

 

cfValues['Soft Booking Needed?']*.value.contains("Yes") ^ cfValues['Soft Booking-Additional Instructions'] == null

 

Regards

Srikanth G

2 answers

0 votes
Knut Arne
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 8, 2018

Hi,

Are you using Scriptrunner Behaviour for this?

If yes, you can add the following script to the "Soft Booking Needed?" field, and change out the customfield ID in the script to the ID of your dependent field.

Hope this helps

import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def currentField = getFieldById(getFieldChanged())
def targetedField = getFieldById("customfield_11641")

String currentFieldValue = currentField.getValue()

if (currentFieldValue == "Yes") {
targetedField.setRequired(true)

}
0 votes
Mark Markov
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 8, 2018

Hello @Srikanth Gogineni

try this

!(cfValues['Soft Booking Needed?']?.value == "Yes" && cfValues['Soft Booking-Additional Instructions'] == null)

 This condition will raise an error, when Soft Booking Needed field sets to Yes and "Soft-Booking-Additional Instructions" is empty

Srikanth Gogineni August 9, 2018

Hi Mark,

 

the above code did not work. any other way to approach

 

regards

Sikanth G

Mark Markov
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 16, 2018

try:

!(cfValues['Soft Booking Needed?']?.value == "Yes" && cfValues['Soft Booking-Additional Instructions']*.value == null)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events