Forums

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

How to set default value to Linked issue depending the issue type that selected

IDO GAFSON November 6, 2022

hello 

 

is there an option to set default value to Linked Issue field base on the selected Issue Type,

I tried few script in script runner (behaviours) none of them works.

 

here example of the script I tried to config:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.*


def issuetype = getIssueContext().getIssueType().name


def linkedIssue = getFieldByName("Linked Issue")
linkedIssue.setFormValue(null)

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def customField = customFieldManager.getCustomFieldObject(selectcf.getFieldId())
def config = customField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(config)


if (issuetype.contains("Bug")) {
def optionsMap = options.findAll {
it.value in ["is bug of"]
}.collectEntries {
[
(it.optionId.toString()): it.value
]
}
linkedIssue.setFieldOptions(optionsMap)
}
else........

 

 

 

1 answer

0 votes
Rafael Costa
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 6, 2022

Hi, @IDO GAFSON .

This code returns any error? If yes, put the error log here

IDO GAFSON November 6, 2022

no error

Suggest an answer

Log in or Sign up to answer