Post function ERROR Cannot Invoke method getRelevantConfig() on null object

sm.park April 28, 2021

Hi,

I added the create a subtask function to the post function. Occurs Cannot Invoke method getRelevantConfig() on null object sometimes. Is there any way to solve this problem?

The code is as follows

 

import com.atlassian.jira.component.ComponentAccessor

 

def optionManager = ComponentAccessor.getOptionsManager()

def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find { it.name = '배포 Site' }

def fieldConfig = cf.getRelevantConfig(issue)

 

 

1 answer

0 votes
Martin Bayer _MoroSystems_ s_r_o__
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 29, 2021

Hi @sm.park it probably occurs when the custom field is not configured for the issue's context. Simple fix (but I would need to have more details to find out whether it is correct or not) is to not to use cf when it is null.

Can you share complete script so we can try it?

sm.park May 3, 2021

Hi, The script is as follows

 

import com.atlassian.jira.component.ComponentAccessor
import org.apache.log4j.Level
import org.apache.log4j.Logger

def log = Logger.getLogger("com.curvc")

def optionsManager = ComponentAccessor.getOptionsManager()
def cf = customFieldManager.getCustomFieldObjects(sourceIssue).find {it.name == "배포 Site"}

def fieldConfig = cf.getRelevantConfig(issue)
def acheck = optionsManager.getOptions(fieldConfig).getOptionForValue("Seosan",null)
issue.setCustomFieldValue(cf,[acheck])

def level = customFieldManager.getCustomFieldObject(14416L) // 요청 Site
def levelvalue = sourceIssue.getCustomFieldValue(level).toString()
def deploytype = customFieldManager.getCustomFieldObjects(issue).find {it.name == '배포유형'}

def fieldConfig1 = deploytype.getRelevantConfig(issue)

log.debug("요청site : "+levelvalue)
log.debug("배포site : "+acheck)
log.debug("배포유형 : "+deploytype)

if(levelvalue == "Seosan"){
def acheck1 = optionsManager.getOptions(fieldConfig1).getOptionForValue("Base",null)
issue.setCustomFieldValue(deploytype,acheck1)
}
else{
def acheck1 = optionsManager.getOptions(fieldConfig1).getOptionForValue("확산",null)
issue.setCustomFieldValue(deploytype,acheck1)
}

Suggest an answer

Log in or Sign up to answer