Hi
The below Script Its working in console to change assignee its updating in history perfectly
but the assignee to me place its not showing the assignee name so please check it and let me know if any updates
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.event.type.EventDispatchOption
import static java.util.Calendar.*
import org.apache.log4j.Category
def loggedInUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issueManager = ComponentAccessor.getIssueManager()
def mySourceIssue = issueManager.getIssueObject("JP-1")
mySourceIssue.getSummary()
mySourceIssue.getProjectObject().getName()
mySourceIssue.getIssueType().getName()
ApplicationUser user =mySourceIssue.getAssignee()
log.error("user name "+ user.getName())
log.error("user name "+ user.getDisplayName())
// update user
String userName = "janakiram";
def userManager = ComponentAccessor.getUserManager()
ApplicationUser modifiedUser = userManager.getUserByName(userName);
MutableIssue mutableIssue = issueManager.getIssueByCurrentKey("JP-1")
mutableIssue.setAssignee(modifiedUser);
issueManager.updateIssue(loggedInUser,mutableIssue,EventDispatchOption.ISSUE_UPDATED,true)
Hi!
As I can understand, you want to use the same script that you used in console, but in a workflow postfunction.
This code should work:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
def issueManager = ComponentAccessor.issueManager
def userManager = ComponentAccessor.userManager
def loggedUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def user = userManager.getUserByName("") //there goes the username
issue.setAssignee(user)
issueManager.updateIssue(loggedUser, issue, EventDispatchOption.ISSUE_UPDATED, true)
It's the same as yours, but without setting the issue variable and without getting current Assignee.
You have to put it on a Script Post Function -> Custom Script Post Function.
Hope it helps,
Marcos
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.