Forums

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

ScriptRunner Behaviour is not working on create Screen

Ulta Tools Admin November 10, 2021

Hi Team , we have created below behaviour but it is not working in create screen ..once ticket created, from there it is working expected .please check the below.

 

import com.atlassian.jira.component.ComponentAccessor
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript


//@BaseScript FieldBehaviours fieldBehaviours
def TypeField = getFieldById("customfield_18811")

String issuetype = getIssueContext().getIssueType().getName()

def optionsManager = ComponentAccessor.getOptionsManager()
def selectListCustomField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(18811)
def fieldConfig = selectListCustomField.getRelevantConfig(getIssueContext())
def options = optionsManager.getOptions(fieldConfig)
def listMap =[:]

if (issuetype == 'Bug'){

def option1 = options.find {it.value == 'Others'}
def option2 = options.find {it.value == 'DEFS4DEV'}
def option3 = options.find {it.value == 'DEFS4CFG'}
def option4 = options.find {it.value == 'DEFECCDV'}
def option5 = options.find {it.value == 'DEFECCCF'}
def option6 = options.find {it.value == 'DEFS4SEC'}
def option7 = options.find {it.value == 'DEFECCSC'}
def option8 = options.find {it.value == 'DEFFIODV'}

listMap.put(option1.getOptionId(),option1.getValue())
listMap.put(option2.getOptionId(),option2.getValue())
listMap.put(option3.getOptionId(),option3.getValue())
listMap.put(option4.getOptionId(),option4.getValue())
listMap.put(option5.getOptionId(),option5.getValue())
listMap.put(option6.getOptionId(),option6.getValue())
listMap.put(option7.getOptionId(),option7.getValue())
listMap.put(option8.getOptionId(),option8.getValue())
TypeField.setFieldOptions(listMap)

}

if (issuetype == 'Sub-task'){

def option1 = options.find {it.value == 'Others'}
def option2 = options.find {it.value == 'ECCDEV'}
def option3 = options.find {it.value == 'CONFIG'}
def option4 = options.find {it.value == 'S4H_CFG'}
def option5 = options.find {it.value == 'S4H_DEV'}
def option6 = options.find {it.value == 'S4H_FIO'}
def option7 = options.find {it.value == 'S4H_SEC'}
def option8 = options.find {it.value == 'SECURITY'}
listMap.put(option1.getOptionId(),option1.getValue())
listMap.put(option2.getOptionId(),option2.getValue())
listMap.put(option3.getOptionId(),option3.getValue())
listMap.put(option4.getOptionId(),option4.getValue())
listMap.put(option5.getOptionId(),option5.getValue())
listMap.put(option6.getOptionId(),option6.getValue())
listMap.put(option7.getOptionId(),option7.getValue())
listMap.put(option8.getOptionId(),option8.getValue())
TypeField.setFieldOptions(listMap)

}

 

 

0 answers

Suggest an answer

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

Atlassian Community Events