Hi there,
I'm writing a groovt script that read parent field and open subtasks related to that field. However, i have a little problem. After i read the parrent field values, i create a loop for creating new subtasks based on number of values in that field. It's working without any trouble. However, my problem is that when it's in the loop, in creating subtask process i want to set the subtask field to comes from the parent one.
Lets Say; Department Field: ABC, ASD (Parent)
After reading the field values (We have two), it creates 2 subtasks. In that subtasks, i want to set the Department field to ABC and ASD seperately. I tried to use issueinputparameters but couldn't make it. I think, i have to convert that value to the one that field can accept, but i have failed.
String value = setTestIterator.next(); //Comes from hashmap issueInputParameters.addCustomFieldValue("customfield_10400", value)
Thanks in advance.
Community moderators have prevented the ability to post new answers.
What is value? It should be the ID of the selected option. So, it should not be a String reading "ABC" or "ASD", but rather a 5-digit number in String form.
Also: Make sure the "Department" field is present in the create screen used when creating the sub-tasks. You can check that by manually creating a subtask in JIRA and setting a value in the "Department" value in the create screen. (Not after that when editing an Issue; the edit screen can be different than the create screen.)
below code is for single select list:
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
MutableIssue issue = event.issue
IssueManager issueManager = componentManager.getIssueManager()
String issueType = issue.issueTypeObject.name
log.debug "Issue Type: " + issueType
def targetFieldName = "Assignment Group"
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
String filepath = "/opt/atlassian/jira/atlassian-jira/WEB-INF/classes/com/icg/SubTastTypeAssignmentGroupMap.txt"
File f = new File(filepath)
String fileContents = new File(filepath).text
if (fileContents.contains(issueType)){
def line = fileContents.split('\n')
def map = [:]
for (int counter = 1; counter < line.length; counter++){
map[line[counter].split(':')[0]] = line[counter].split(':')[1]
}
def nameofgroup = map.find{it.key == issueType }
String groupname = nameofgroup.value
log.debug "Group Name: " + groupname
try{
Group watcherGroup = componentManager.getUserUtil().getGroup(groupname.trim())
List<Group> groupList = new ArrayList<Group>()
groupList.add(watcherGroup)
CustomField customFieldTarget = customFieldManager.getCustomFieldObjectByName(targetFieldName)
customFieldTarget.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(customFieldTarget),groupList), changeHolder)
log.debug "updated group"
}
catch(e){
log.debug "Exception Occurred"
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
what type of control it is.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.