It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to validate some set of string in a text field?

Hello,

I am trying to add a validation which catches 'Caused By Explanation' string inside a multi text field. And throws an exception to show users saying 'Caused By Explanation' is not a valid value.

How to achieve this? 

 

1 answer

1 accepted

1 vote
Answer accepted
Leo Community Leader Nov 15, 2019

Hi @Tejas Naik,

Below snippet may help you

import com.atlassian.jira.component.ComponentAccessor
import com.opensymphony.workflow.InvalidInputException

def cField = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Caused By Explanation")
def value = issue.getCustomFieldValue(cField) as String

if (value == "Something"){
return true
}
else{
throw invalidInputException = new InvalidInputException("Custom Error")
}

 BR,

Leo

@Leo Thanks, It worked.

Regards

Tejas Naik

Suggest an answer

Log in or Sign up to answer
TAGS

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