Hi Community!
I am trying to create subtasks for an issue, in a Service Management project as a post function during create transition. It is based on a multi select custom field, so that one subtask is to be created for each selected item.
However the script runs into a permission error when a user outside of the service management group is trying to create the issue.
Heres the simplified script:
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.config.manager.PrioritySchemeManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.event.type.EventDispatchOption
import com.onresolve.scriptrunner.runner.customisers.PluginModule
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
//get technical user
def techUser = ComponentAccessor.getUserManager().getUserByName("techuser")
// the priority of the new issue
def priorityName = issue.priority.getName()
def issueService = ComponentAccessor.getIssueService()
def constantsManager = ComponentAccessor.constantsManager
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def prioritySchemeManager = ComponentAccessor.getComponent(PrioritySchemeManager)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def parentIssue = ComponentAccessor.issueManager.getIssueByCurrentKey(issue.key)
def subTaskIssueType = constantsManager.getIssueType('11101')
//set reporter as reporter of sub-tasks
def reporter = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def priorityId = constantsManager.priorities.findByName(priorityName)?.id
String subSummary = "subSummary"
String subDescription = "subDescription"
def issueInputParameters = issueService.newIssueInputParameters()
issueInputParameters.setSkipScreenCheck(true)
issueInputParameters.setProjectId(parentIssue.projectObject.id)
issueInputParameters.setIssueTypeId(subTaskIssueType.id)
issueInputParameters.setReporterId(reporter.username)
issueInputParameters.setSummary(subSummary)
issueInputParameters.setPriorityId(priorityId)
issueInputParameters.setDescription(subDescription)
def validationResult = issueService.validateSubTaskCreate(techUser, parentIssue.id, issueInputParameters)
assert validationResult.valid : validationResult.errorCollection
def issueResult = issueService.create(techUser, validationResult)
assert issueResult.valid : issueResult.errorCollection
//set issue parent - sub-task link
def subtask = issueResult.issue
ComponentAccessor.subTaskManager.createSubTaskIssueLink(parentIssue, subtask, techUser)
When it runs it throws the following error:
What am I missing?
Any help would be appreciated!
Thanks