Custom Fields with weighted values

Christophe Siclari June 24, 2022

Hello,

 

I have a question and I could not find something about it.

Please note that I'm very new with the tool.

 

I would like to create a field (custom field) where the value has a certain weight according to the selected value.

And at the end I would like to display the result of all weights (additional)

 

 

I will be easier to understand with an example:

 

Question 1 : How many users ?

  • 2 users (Weight: 0)
  • 3 users (Weight: 20)
  • 4 users (Weight: 50)

 

Question 2 : Deployment time ?

  • 30 min (Weight: 0)
  • 60 min (Weight: 30)
  • 90 min (Weight: 40)

 

Let' assume the choices are respectively (3 users and 90 mins) - the weight would be (20+40) 60

 

I'd like the user to chose one answer per question and the result (weight) to be calculated automatically and displayed at the end of the form.

 

Is this possible? If yes - how ?

Please note that I installed (trial version) the Jira Misc Custom Fields (JMCF) plugin.

 

Many thanks.

 

 

Kind regards,

Chris

 

 

 

1 answer

0 votes
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 24, 2022

Hi @Christophe Siclari 

with JMCF, you'll be able to create a Calculated Number field that represents the total weight. However, the value will only be visible after the "form" (I assume you mean the issue creation screen or a transition screen, or maybe a Jira Service Management request creation form) is submitted. The field will be visible on the issue view after its creation.

Would that work for you?

Christophe Siclari June 27, 2022

Dear David,

 

Thanks for your answer.

Yes, it should be ok as from the moment the value is displayed before the validation.

 

How can I proceed, currently I'm not even able to assign a weight to an answer.

 

Thanks

 

Regards,

Chris

David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 27, 2022

Hi @Christophe Siclari 

you can use a formula like this:

def weight = 0

switch (issue.get("Question 1 : How many users ?")) {
case "2 users":
break;
case "3 users":
weight += 20;
break;
case "4 users":
weight += 50;
break;
}

switch (issue.get("Question 2 : Deployment time ?")) {
case "30 min":
break;
case "60 min":
weight += 30;
break;
case "90 min":
weight += 40;
break;
}

return weight;

Of course, you'll need to make sure the values and field names match exactly your setup. You might also want to replace field names with field IDs - use the "Issue Fields" help tab at the bottom of the script editor to find the field IDs. 

Christophe Siclari June 29, 2022

Hello David,

 

Thanks for the formula.

I was able what I wanted :)

 

Regards,

Chris

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events