Hi
I have created a custom listener script below ( and this is my first time doing that ) that assigns the issue ( created / edited ) to certain user based on certain custom field value but I got an issue :
1- I need the script to run on the current issue instead of putting its key manually in getIssueByCurrentKey I have tried to use issue.getKey() but faced the error below :
groovy.lang.MissingMethodException: No signature of method: static com.atlassian.jira.issue.MutableIssue.getKey() is applicable for argument types: () values: [] Possible solutions: getAt(java.lang.String), notify(), every(), grep(), grep(java.lang.Object), every(groovy.lang.Closure) at Script736.run(Script736.groovy:32)
UPDATE
I have solved the problem as I said in my reply to the first comment.
here is the new working code :
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
import org.apache.log4j.Level
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.IssueInputParametersImpl
import com.atlassian.jira.event.issue.IssueEvent
def logg = Logger.getLogger("com.acme.CreateSubtask")
logg.setLevel(Level.DEBUG)
String user;
def cfManager = ComponentAccessor.getCustomFieldManager();
def cf = cfManager.getCustomFieldObject("customfield_32946");
def cfVal = issue.getCustomFieldValue(cf)
def userr = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
switch(cfVal as String){
case { it == "[Assistant, Ask to Google]" || it == "[Assistant, Request to Google]" || it == "[Assistant, VF Office Hours]" }:
user = "hossam@it.com";
break;
}
logg.debug issue
def issueService = ComponentAccessor.issueService
def issueInputParameters = new IssueInputParametersImpl()
issueInputParameters.setAssigneeId(user)
def updateValidationResult = issueService.validateUpdate(userr, issue.id, issueInputParameters)
issueService.update(userr, updateValidationResult, EventDispatchOption.ISSUE_UPDATED, false)