from com atlassian jira component import ComponentAccessor cfM Compone

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from com.atlassian.jira.component import ComponentAccessor
cfM = ComponentAccessor.getCustomFieldManager()
allowed_actions = {23116:111, 23117:101}
def gcfv(id):
return issue.getCustomFieldValue(cfM.getCustomFieldObject(id))
def setTransition(transition_id):
from com.atlassian.jira.workflow import WorkflowTransitionUtilImpl
from com.atlassian.jira.util import JiraUtils
wftUtil = JiraUtils.loadComponent(WorkflowTransitionUtilImpl)
wftUtil.setIssue(issue)
wftUtil.setAction(transition_id) # transition ID
wftUtil.setUsername('jellyrunner')
wftUtil.validate()
wftUtil.progress()
reason_id = gcfv(25800)[0].getOptionId()
if reason_id in allowed_actions.keys():
setTransition(allowed_actions[reason_id])