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
Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.
Register today!Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.