Forums

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

I need a script

Sai Krishna Katta November 8, 2021

Hi Team,

I wanted to make a custiomfield "DONTKNOW" mandatory on Resolve transitions for only 3 issuetypes.

if customfield "DONTKNOW" = (paricular value say else) "Else" then custom field should be mandatory.

1 answer

0 votes
Payne
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.
November 9, 2021

Your subject states that you "need a script" - does that imply that you have an app that supports scripting, such as ScriptRunner or JMWE?

Sai Krishna Katta November 9, 2021

Yes, I have both.

Payne
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.
November 9, 2021

Cool. With those apps, you can create a scripted validator with code something like the following (it's not tested, but should be pretty accurate.)

import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

CustomField dontKnowField = customFieldManager.getCustomFieldObjectsByName("DONTKNOW")[0]
String dontKnowValue = issue.getCustomFieldValue(dontKnowField)

String issueTypeName = issue.getType().getName()

List issueTypes = ["Issue Type 1","Issue Type 2","Issue Type 3"]

if(issueTypeName in issueTypes && dontKnowValue == "")
{
return false
}
else
{
return true
}

Suggest an answer

Log in or Sign up to answer