Set multi select list to new value using Issue input parameters

Ali Ozkan April 23, 2014

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.

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Andreas Ebert
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2014

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.)

0 votes
Paresh Gandhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 24, 2014

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"

}

}

}

0 votes
Paresh Gandhi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 23, 2014

what type of control it is.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events