Behaviour plugin - set version field

Marc Minten _EVS_
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.
December 8, 2014

Hi,

 

I want to set a default value for the Fix Version/s field of an issue (Story) created from an Epic. The default value should be the current Fix Version/s of the Epic issue.

Here a code extract:

// Get Epic linked to this issue
FormField epicField = getFieldByName("Epic Link")
def epicKey = epicField.getFormValue().replaceAll("key:","")
def epic = issueManager.getIssueObject(epicKey)
def fixVersions = epic.getFixVersions()
if (fixVersions.size() > 0) {
    FormField fldFixVersion = getFieldById("fixVersions")
    fldFixVersion.setFormValue(fixVersions)
}

Something does not work (setFormValue() ???). In the log I find

http-bio-8080-exec-4 DEBUG [onresolve.jira.groovy.BehaviourManagerImpl] Returning map: [fixVersions:[setValue:[V1], fieldType:com.atlassian.jira.issue.fields.FixVersionsSystemField, displayName:Fix Version/s]]

, "V1" is the name of the version in the Fix Version/s field of the Epic. The code in the log file seems to be correct. Why do I not see the value ("V1") in the Fix Version/s field of the issue I create ???

 

JIRA 6.1.6

Behaviour plugin 0.5.10

2 answers

1 accepted

1 vote
Answer accepted
JamieA
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.
December 8, 2014

getFixVersions() returns you a list of Version objects. But when you set the form value you need to pass it a list of version IDs.

So try replacing with:

fldFixVersion.setFormValue(fixVersions*.id)

This will only work as you expect if the issue being created is in the same project as its epic. If not those IDs won't be valid for fix versions in the other project. 

1 vote
Marc Minten _EVS_
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.
December 8, 2014

Hi Jamie,

This works indeed. Thanks for your quick and valuable help (as always smile)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events