Forums

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

Need help with Validator script to make field mandatory with conditions (Validator)

satyanarayana_singamsetti
Contributor
March 26, 2025

Hi All,

 

I need to have Validator script for below scenario

Field3 need to be Mandatory and with condition

Field1 with value V1 And Field2 != null And during Transition from Open to InProgress status

 

Could someone please help me with the script?

 

Is there any other ways apart validator, we can implement it?

 

Regards,

Satya

 

 

1 answer

0 votes
Charlotte Santos -Appfire-
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 26, 2025

Hi @satyanarayana_singamsetti

I’m Charlotte, a support engineer at Appfire and I’m here to help you.

You didn’t mention what app you’re using to make the field mandatory.

If you have Jira Misc Workflow Extensions (JMWE) installed, you can use the Field Required Validator (JMWE app), that allows you to make a field required but with conditions.

For your specific case, I recommend doing something like this (I imagined that both fields were select list):

Screenshot 2025-03-26 at 12.51.25.png

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.customfields.option.Option


def customFieldManager = ComponentAccessor.customFieldManager


// Get field objects - replace with your exact field names

def field1 = customFieldManager.getCustomFieldObjectsByName("Mandatory")?.first()

def field2 = customFieldManager.getCustomFieldObjectsByName("Area")?.first()


// Get the selected options

def field1Option = issue.getCustomFieldValue(field1) as Option

def field2Option = issue.getCustomFieldValue(field2) as Option


// Check conditions

def field1IsV1 = field1Option?.value == "Yes"  // Compare with option value

def field2IsSelected = field2Option != null   // Just check if any option is selected


// Return true only when both conditions are met

return field1IsV1 && field2IsSelected

You only need to update the script with the name of the fields and the options you use in your instance.

Please contact our support if you have any other questions about this validator, or JMWE in general.

We’ll be happy to help you! 😉

satyanarayana_singamsetti
Contributor
March 26, 2025

HI,

 

Thanks for the info

We are not having JMWE plugin in our application. We only have ScriptRunner.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events