Hello,
Based on count of values chosen in a field ("Test1" in my example) in customer portal, I need linked issues to be created, so that in case 3 values are chosen in customer portal, 3 linked issues should be created.
I solved the problem by using subtasks, but as subtasks in Service Desk do not support approval process, I need to use linked issues in stead of subtasks. Can you please help with some code? Here is my code, using subtasks:
IssueManager im = ComponentAccessor.getIssueManager()
MutableIssue issue = im.getIssueObject("SDAT-1156")
def customFieldManager = ComponentAccessor.customFieldManagerdef cField = customFieldManager.getCustomFieldObjectsByName("Test1")[0]
def cFieldValue = cField ? issue.getCustomFieldValue(cField) : "Field doesn't exist"
//// For Sub tasks ////////
def constantManager = ComponentAccessor.getConstantsManager()
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def issueManager = ComponentAccessor.getIssueManager()
Issue parentIssue = issuedef reporter = parentIssue.reporter.namelog.warn("The reporter is " + reporter)
log.warn "====================Start of Log=============================="
log.warn "Custom field value type or class" + cFieldValue.getClass()def cascadingSelect = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Group owner")
log.warn cascadingSelect
cFieldValue.each{i->
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setAssigneeId(parentIssue.assigneeId)
newSubTask.setSummary("$i")
newSubTask.setReporter(parentIssue.reporter)
newSubTask.setParentObject(parentIssue)
newSubTask.setProjectObject(parentIssue.getProjectObject())
newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{
it.getName() == "Group-SubTask"
}.id)
def newIssueParams = ["issue" : newSubTask] as Map<String,Object>
// for JIRA v7.* and V8.*
issueManager.createIssueObject(user, newIssueParams)
subTaskManager.createSubTaskIssueLink(parentIssue, newSubTask, user) log.warn "Issue with summary ${newSubTask.summary} created"
log.warn "Group is: $i "
}
log.warn "Selected groups are: " +cFieldValue
log.warn "Reporter is: " + reporter
log.warn "====================End of Log=============================="
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.