Behaviors not behaving

I'm trying to configure a JIRA plug-in called Behaviors to calculate a field by using data from two other fields. So far I've had no luck with the configuration or online help.

I am unable to figure out the exact issue here. Somehow, our script is unable to read the “formField” object. This object is supposed to be activated with Behaviors plugin as it (formField object) is not available with JIRA’s default classes:

https://developer.atlassian.com/static/javadoc/jira/6.0.5/reference/classes.html

Any guidance is helpful.

6 answers

Can you post the xml of the behaviour you've got troubles with ?

Please see the code posted by my team mate Vaibhav below. Does that give you enough info to help us out?

Hello Josh,

here some examples https://jamieechlin.atlassian.net/wiki/display/JBHV/JIRA%20Behaviours%20Plugin#JIRABehavioursPlugin-Setonefieldbasedonanotherfieldwithinformationprovidedbytheserver

If you provide us your code we can help you on that.

Please make sure that you defined a correct mapping (project/issue type) for your behaviour.

Hope this helps,

Fabio

Please see the code posted by my team mate Vaibhav below. Does that give you enough info to help us out?

Hi guys,

I belive I have done proper mappings. Below is the simple behaviour's code we are facing trouble with:

F1 = getFieldByName('MyFieldInput1').getValue()
F2 = getFieldByName('MyFieldInput2').getValue()

FormField out = getFieldByName('MyFieldOutput')

if (F1 == 'Likely' && F2 == 'Critical') {
  out.setFormValue("R1") 
}

Requirement: Based on the values set in MyFieldInput1 and MyFieldInput2, my 3rd JIRA input field's value should be influenced.

Like in above case if the values in MyFieldInput1 and MyFieldInput2 are "Likely" and "Critical" respectively, then my out JIRA field should have text value as: "R1"

What type of field is MyFieldOutput?

Add some logging, eg

log.warn ("F1: " + F1)
log.warn ("F2: " + F2)

and look in the jira log after activating the bejaviour.

Also please don't start your variables with an upper case char.

In private emails you said that all fields are select lists.

To set a select list value you will need to send the option ID, which is like 12345.

This is not ideal but this is how it works right now. Maybe in future there will be a setValue() method, like the getValue() method, which has a bit more smarts.

Hi Jamie,

Thanks for your reply. I'll work on your suggestion and revert with the results.

Hi Jamie,

Where to get this option ID?

Also, the field which is being set depeding on the other two "Select List" fields is "Scripted Field".

Should I change the output field to text field?

This is not making any sense. You can't set the value of a scripted field.

You modify the script field code so that it returns a value based on the two select lists.

Oh, I thought that since the output filed is changing as per the script, we are required to set it to "Scripted Field"

Should I change the output field to "Text Field" if that will make it smooth?

You can use a behaviour to set a text field from other the values of other fields.

You can use a script field to display a value based on other fields.

The first approach lets the user override the value. Horses for courses.

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,321 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