Hello,
I need a listener that assigns the issue to a default assignee, whenever the issues workflow is transitioned to a specific status. My idea:
1. Listener listens to updates of the issues --> then fires
2. If worflow status matches the corresponding ID and issueType matches corresponding issuetype --> the assigne should be set to XY
my code here:
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.util.UserManager
//Workflow imports
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.workflow.JiraWorkflow
import com.atlassian.jira.workflow.WorkflowManager
// Variabels
String issueTypeId_IST = "10202"
def WfId_Soll = "2"
//Workflow
WorkflowManager workflowManager = ComponentAccessor.getWorkflowManager()
//Preps
def issueManager = ComponentAccessor.getIssueManager()
def issueService = ComponentAccessor.getIssueService()
def userManager = ComponentAccessor.getUserManager()
ApplicationUser loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def user = userManager.getUserByName("lehrkraftsuchen")
log.info("step1: Listener fires due to updating issues")
// Get Issue
def issue = event.getIssue()
JiraWorkflow workflow = workflowManager.getWorkflow(issue)
def issueTypeId_IST = issue.getIssueTypeId()
def WfId_IST = workflow.getLinkedStep(issue.getStatus()).id
log.info("das Issue lautet:"+issue)
log.info("Issuetype ID IST:"+issueTypeId_IST)
log.info("Issuetype ID SOLL:"+issueTypeId_Soll)
log.info("WF ID IST:"+ WfIdI_ST)
log.info("WF ID SOLL:"+ WfId_Soll)
if (issueTypeId_IST != issueTypeId_Soll || WfId_IST != WfId_Soll) {
log.info("IF clause does not match")
return
}
def validateAssignResult = issueService.validateAssign(loggedInUser, issue.id, "lehrkraftsuchen")
issueService.assign(loggedInUser, validateAssignResult)
log.info("der assignee wurde geändert"+ issue.getAssignee())
As you see I use log.info with some interestin resoults. In the logs I can see that everything matches the way I want it to match and still the code gets returned, due to the if clause. but this is not logical. Neither the issuetype or the WFId ist "unequalt" a true value...
Why does this code doesnt work? I also tried this if-clause:
if (issueTypeId_IST == issueTypeId_Soll && WfId_IST == WfId_Soll){
**further code**
} Thanks for your aswers