Forums

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

How to validate a checkbox?

Pranita Warik September 28, 2020

I have two single select fields in my project:

Field1 is Signature: Signed, Not Signed (its values)

Field2 is Category: Revex, Capex (its values)

 

I have a Documents checkbox with four options:

1. invoices attached

2. Approval mail attached (for not signed)

3. Revex docs attached

4. Capex docs attached

 

On Create Issue, I want the checkbox validation to be as:

If Signature field is Not Signed, then the user must tick the option 2 of checkbox

If Category field is Revex, then the user must tick the option 3 of checkbox

If Category field is Capex, then the user must tick the option 4 of checkbox

The user must always tick the option 1

 

How can I achieve this using JSU? 

2 answers

1 accepted

0 votes
Answer accepted
Pranita Warik September 29, 2020

I was able to achieve the validation as mentioned in the question using a ScriptRunner Build In validators. I used Simple Scripted Validator for each of the conditions. Examples  were very helpful to get started with. 

If Signature field is Not Signed, then the user must tick the option 2 of checkbox

cfValues['Signature']?.value!= "Not Signed" || cfValues['Documents']*.value.contains("Approval mail attached (for not signed)") 

Did it similarly for below two conditions:

If Category field is Revex, then the user must tick the option 3 of checkbox

If Category field is Capex, then the user must tick the option 4 of checkbox

The user must always tick the option 1:

cfValues['Documents']*.value.contains("invoices attached") //i.e. option 1

Important Note: The value in contains() should be the exact value of the option. 

Sneha Kumari
Contributor
May 20, 2021

Hi @Pranita Warik 

This doesn't work in Jira Cloud. Could you please help me with the script for the cloud instance.

I am trying to add the following validator script to Workflow but getting the following error.

cfValues['Sub-Status']*.value.contains("On hold")

Here 'Sub-Status' is a checkbox field having only 1 value 'On hold' currently.

Error Validator.PNG

Thanks in advance.

Sneha

0 votes
Denise_Wuethrich_beecom_products
Contributor
September 28, 2020

Hi, @Pranita Warik We'd love to help you with your special use case. Kindly create a ticket here so we could help you configure. Thank you. 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.5.1
TAGS
AUG Leaders

Atlassian Community Events