Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,293,678
Community Members
 
Community Events
165
Community Groups

Field Required Validator or Behavior

Hi Team,

 

I want few fields required upon closing of ticket via scriptrunner or JSU, as this 2 add-ons we have.

So When some one click Close request and if Field A = ABC then it should check if field X & Y is not empty. Trying on various ways but couldnt succeed.

Trying Field Required Validator (Scriptrunner) but no luck, behavior will not fit as I need this on workflow transition. This is what I am using on behavior side but thats also not working.

Please help here for this one to make it work on workflow transition and what should I use.

import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
 
def FieldA = getFieldById("customfield_15600")
FormField TrAMSFunctionalArea = getFieldById("customfield_15702")
String FieldA = (String) FieldA.getValue()
 
if (FieldA.equals("ABC") {
FieldX.setRequired(true)
FieldY.setRequired(true)
}
else {
FieldX.setRequired(false)
FieldY.setRequired(False)
}

2 answers

Hi Rakesh, 

Here is a documentation that explain how to do it with apps such as JSU or Scriptrunner... do not code for that, there are existing validator with JSU or Scriptrunner ;) 

https://confluence.atlassian.com/jirakb/make-custom-fields-required-in-a-workflow-transition-in-jira-server-691011903.html

I hope this helps ;) 

Cheers,
Dam.

0 votes
Tansu Akdeniz Community Leader Jun 23, 2022

Hi @Rakesh Jajper 

Do all the fields exist in Close transition screen? If not, getFieldById("customfield_xxxxx") doesn't work in bhv.

Also, I couldn't see FieldX and FieldY definition in your code.

I suggest you use setHelpText() within the code to see variable values step by step.

As I see, you use same variable "FieldA" twice in the code. Change to:

String FieldAVal = (String) FieldA.getValue()
Please also check this doc.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,121 views 34 44
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you