Behaviour plugin - set version field

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

0 vote

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. 

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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Apr 10, 2018 in Marketplace Apps

Learn about how Stefan K. built one of the *first ever* Marketplace apps

In this post you will discover more about the evolution of K15t software, some big topics they're currently focusing on in the app space, and a rare (not not funny!) photo of founders Mike Cannon-Bro...

12,831 views 11 24
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you