Hi
I have a few error in the Custom script post-function
can you help me?
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
def constantManager = ComponentAccessor.getConstantsManager()
def issueManager = ComponentAccessor.getIssueManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def subTaskManager = ComponentAccessor.getSubTaskManager()
def personFieldsIds = [14098,14099]
for (int personFieldsId:personFieldsIds){
def person = customFieldManager.getCustomFieldObject(personFieldsId)
def personValue = issue.getCustomFieldValue(person)
if (personValue){
MutableIssue newSubTask = issueFactory.getIssue()
newSubTask.setReporter(issue.reporter)
newSubTask.setAssignee(personValue?.getKey())
newSubTask.setSummary("Subtask for " + personValue?.getDisplayName())
newSubTask.setParentObject(issue)
newSubTask.setProjectObject(issue.getProjectObject())
newSubTask.setIssueTypeId(constantManager.getAllIssueTypeObjects().find{it.getName() == "Sub-task"}.id)
newSubTask.setDescription("Description for " + personValue?.getDisplayName())
Map<String,Object> newIssueParams = ["issue" : newSubTask] as Map<String,Object>
issueManager.createIssueObject(issue.reporter, newIssueParams)
subTaskManager.createSubTaskIssueLink(issue, newSubTask, issue.reporter)
}
}
Jira v 6.3.10
You're not defining customFieldManager before using it. You need a line like
def customFieldManager = ComponentAccessor.getCustomFieldManager()
It may not completely solve your problem, but it is certainly one error. Nic noted another error about your array of IDs.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Line 12 does not work because you're passing an array of numbers into a function that is expecting a single ID. This chains down into all of the other errors, so fix that (by using a single field to read, rather than two), and it should be ok.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Again, you are passing the wrong thing into the getCustomFieldObject call - it needs a single field reference, not a string that looks like the display of an array with two field ids in it.
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.