Behaviors not behaving

Josh Kebbel-Wyen May 15, 2014

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

0 votes
Vaibhav Gupta June 24, 2014

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?

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.
June 24, 2014

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.

0 votes
Vaibhav Gupta June 24, 2014

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?

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.
June 24, 2014

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.

0 votes
Vaibhav Gupta June 23, 2014

Hi Jamie,

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

0 votes
Vaibhav Gupta May 22, 2014

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"

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.
June 18, 2014

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.

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.
June 24, 2014

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.

0 votes
Fabio Racobaldo _Herzum_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
May 16, 2014

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

Josh Kebbel-Wyen May 28, 2014

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

0 votes
Boris Georgiev _Appfire_
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.
May 16, 2014

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

Josh Kebbel-Wyen May 28, 2014

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

Suggest an answer

Log in or Sign up to answer