Hi
I am using following code to set the reporter of the issue that is being created
def issueInputParameters = issueService.newIssueInputParameters().with {
setIssueTypeId(currentIssueType.id)
setReporterId((ComponentAccessor.userManager.getUserByName("ReporterName") ).key)
setSummary(summary)
setPriorityId((constantsManager.priorities.findByName(priorityName) ?: constantsManager.defaultPriority).id)
}
Issue gets created correctly, however I have noticed that the "Reporter" and "Assignee" both are set to admin which is the user that executes the automation rule.
Question: How do I get the "ReporterName" assigned to the Reporter jira attribute.
Also, how do the set the assignee as well in the IssueInputParameters?
Thanks in advance.
Hi,
I use this to set the reporter
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
log.warn(loggedInUser.name)
issueInputParameters
.setProjectId(project.id)
.setIssueTypeId("10001")
.setReporterId(loggedInUser.name)
I think is the same thing for the assignee. Make sure you do not have a automation rule that overwrite assignee and reporter field
Hi Mohamed,
Thank you for your response.
I tried your suggestion but still it is setting the admin user.
My code is as follows
===================================================
def validationResult;
ComponentAccessor.jiraAuthenticationContext.setLoggedInUser(loggedInUser) ;
def project = ComponentAccessor.projectManager.getProjectObjByKey(projectName);
def projectComponentManager = ComponentAccessor.getProjectComponentManager();
def issueService = ComponentAccessor.issueService
def constantsManager = ComponentAccessor.constantsManager
def issueInputParameters = issueService.newIssueInputParameters().with {
setProjectId((taskType == "Primary") ? project.id : parentIssue.projectObject.id)
setIssueTypeId(currentIssueType.id)
setReporterId(loggedInUser.name)
setSummary(summary)
setPriorityId((constantsManager.priorities.findByName(priorityName) ?: constantsManager.defaultPriority).id)
}
validationResult = (taskType == "Primary") ? issueService.validateCreate(loggedInUser, issueInputParameters) :
issueService.validateSubTaskCreate(loggedInUser, parentIssue.id, issueInputParameters);
def issueResult = issueService.create(loggedInUser, validationResult);
===================================================
Admin user is the one that is executing the automation rule and hence it is setting the same user as Reporter and Assignee.
LoggedInUser is not the admin user.
In fact, I am creating primary and sub task from a CSV file which contains the reporter and assignee value.
What I want to achieve is that if the Reporter does not exists then set to "Anonymous"
and similary Assignee to "Unassigned"
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Abdul ,
Based on the script, it seems there are more script above that set the loggedInUser.
Alternatively, you can set and get the desired reporter or assignee manually. For example, declare another line to get the user information of the desired reporter or assignee.
import com.atlassian.jira.user.ApplicationUser
//get the desired reporter and assignee user information
ApplicationUser reporter = ComponentAccessor.getUserManager().getUserByName("kim") //eg: username is kim
ApplicationUser assignee = ComponentAccessor.getUserManager().getUserByName("loong") //eg: username is loong
...
//set the reporter and assignee
setReporterId(reporter.id)
setAssigneeId(assignee.id)
If the reporter value is returning a null basically setting Anonymous to the issue reporter. You may also verify the project is allowing Anonymous issue creation, see JIRAKB - How to allow users to create issues anonymously.
I hope this helps.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.