I'm currently working on a Jython post-function script that will copy the input of a field (separate Jira project) on a screen from a transition in Service Desk and make a copy of the Jira SD ticket to the selected project. The issue is when the input is left blank (none), it throws the following:
root cause: Traceback (most recent call last): File "/mnt/NewSanDatacenter/jira/jss/jython/workflow/clone_and_move.py", line 21, in <module> pkey = cfm.getCustomFieldObject('customfield_12019').getValue(issue).getKey() AttributeError: 'NoneType' object has no attribute 'getKey'The script in question is written in
import com.atlassian.jira.issue;
from com.atlassian.jira.issue import ModifiedValue, DefaultIssueFactory
from com.atlassian.jira.issue.link import DefaultIssueLinkTypeManager
from com.atlassian.jira.component import ComponentAccessor;
from com.atlassian.jira.util import JiraUtils
im = ComponentAccessor.getIssueManager();
am = ComponentAccessor.getJiraAuthenticationContext();
pm = ComponentAccessor.getProjectManager();
ilm = ComponentAccessor.getIssueLinkManager()
cfm = ComponentAccessor.getCustomFieldManager();
isf = JiraUtils.loadComponent(DefaultIssueFactory);
iltm = JiraUtils.loadComponent(DefaultIssueLinkTypeManager)
curUser = am.getLoggedInUser()
newissuet = isf.cloneIssue(issue)
pkey = cfm.getCustomFieldObject('customfield_12019').getValue(issue).getKey()
project = pm.getProjectObjByKey(pkey)
newissuet.setProjectObject(project)
newissuet.setReporter(curUser)
newissue = im.createIssueObject(curUser, newissuet)
linktype = iltm.getIssueLinkTypesByName('Relates')[0]
r = ilm.createIssueLink(issue.id, newissue.id, linktype.id, 1, curUser)Any ideas what I should add here?