Get Affected Versions or copy to custom field (groovy / behaviours plugin)

Hi,

I'm facing the following problem. I'calculating a "defect value" using groovy scripts and the behaviours plugin. Now I need to integrate the value of the "affected version field" into my calculation. Not really the value but I'd map the version to a numeric value (like: current version 1.5.5--> value 10, next planned version 1.5.6--> value 9 etc. ).

So I either have to get the list and go on from there or copy the value to a custom text field. From there I know how to use the plugin to do what I want...

Can anyone help me out here? I guess I must obtain the versions with sth. like "issue.getAffectedVersions()" but I'm not sure how to really achieve this.

Any help is being appreciated,

Cheers Christian

1 answer

1 accepted

0 vote

Can you be a bit more specific about where you need help? What context is this, eg post-function, or behaviour script?

It sounds like you need the affected version field, then to work out your numeric value you also need to get the list of unreleased versions for that project, using VersionManager.getVersionsUnreleased(...).

Hey Jamie,

it's supposed be be a behaviours script. I got one script (see last part attached) calculation the "defect value" (mapped to defect value field)

// Define and map value
FormField AGE = getFieldByName("Alter (Release)") //11514
def AGE_OPT = AGE.getFormValue()
float AGE_VAL

if (AGE_OPT == "10987"){
AGE_VAL = 4}
else if (AGE_OPT == "10936"){
AGE_VAL = 3}
else if (AGE_OPT == "10974"){
AGE_VAL = 2}
else if (AGE_OPT == "10924"){
AGE_VAL = 1}
else {
AGE_VAL = 0}

log.debug("--------------------Wert von AGE="+AGE_VAL)


/* ################################     Berechnung Gesamtwert    ##################################################*/

float GK_WEIGHT = 4.0
float DS_WEIGHT = 3.56
float KORR_WEIGHT = 3.11
float NEG_WEIGHT = 0.89
float BAKD_WEIGHT = 2.67
float GA_WEIGHT = 1.78
float WORK_WEIGHT = 1.78
float REP_WEIGHT = 0.89
float AGE_WEIGHT = 0.44
      
float Fehlerwert_float= (GK_VAL*GK_WEIGHT)+(DS_VAL*DS_WEIGHT)+(KORR_VAL*KORR_WEIGHT)+(NEG_VAL*NEG_WEIGHT)+(BAKD_VAL*BAKD_WEIGHT)+(GA_VAL*GA_WEIGHT)+(WORK_VAL*WORK_WEIGHT)+(REP_VAL*REP_WEIGHT)+(AGE_VAL*AGE_WEIGHT)

What I was planning to do now is read the "affected version field" value and set the "("Alter (Release)" custom field accordingly. (mapped to affects version field)

Sth. like:

FormField AGE = getFieldByName("Alter (Release)")

<CODE to get the affectedVersion>

if (affectedVersion == "1.5.1"){
AGE.setFormValue("10987") //renders to "Current Release"
}
else if(affectedVersion == "1.5.2")
{AGE.setFormValue("10987") //renders to "Next Release"
}
...

Hope that this explains my problem better than the information I had provided before.

Hi... I think I get what you're trying to do... ie perform a complicated calculation then set a form value. What's the actual problem - you can't get the fixVersions from the form? Try

getFieldById("fixVersions").getValue()

I needed the "affects Version" field. getFieldById("versions").getValue() did the trick! Don't know why this didn't work in the beginning. Maybe I had a typo. Thank you so much.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,277 views 14 20
Join discussion

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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot