Hello,
How to auto update the issue status on custom field value selection?
Example: we have an custom field called "Rejection" and it has options A & B if user selects option A issue should automatically move to Rejected status.
Thanks in Advance,
Mani
Hi mani@123 ,
Kindly try this script :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.util.JiraUtils
import com.atlassian.jira.workflow.WorkflowTransitionUtil
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def selectListChanged = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Rejection"}
if (selectListChanged){
int selectListId = 13500
def selectList = customFieldManager.getCustomFieldObject(selectListId)
def selectListValue = issue.getCustomFieldValue(selectList)
if (selectListValue?.getValue() == "A") {
def transitionId = 21
WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);
workflowTransitionUtil.setIssue(issue);
workflowTransitionUtil.setUserkey("berry_a")
//Alternatively if you want to trigger the transition with the reporter use this
//workflowTransitionUtil.setUserkey(issue.getReporter().getKey())
workflowTransitionUtil.setAction(transitionId);
workflowTransitionUtil.progress();
}
}
(replace custom field and transition id). Use this in script listener for Issue Updated event.
Antoine
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.