Prepopulation of fields using Behaviours plugin

Mizan
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.
March 27, 2012

I am using behaviours plugin to add behaviour to 2 fields consider A and B .
A is a multiple select version picker customfield and B is a single select version picker customfield.

I have modified this script to add options to A and B based on each other .
when options in A are selected option in B are automatically prepopulated
However even before i select the a option in A , the behaviour occurs and i see only "None" as the option while B is a verion picker i should be able to see the versions of the project.

Similary while i select B i am trying to prepopulate value in A but that is not happening because i cant see any option in B other than "None"

And even after i remove the option from A i am able to see the corresponding values in B , It should get removed when option is removed.

How to tackle this ?
is there something i am missing ?

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
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.
March 27, 2012

All of the server-side scripts fire the first time the form is loaded, this is by design.

If you want all options to be available if A and B are uninitialised then you need to code that in. So only restrict the values of B if A is set. And vice versa.

Mizan
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.
March 27, 2012

I figured it out . i added a return statement in my code if no value is selected

FormField formComponent = getFieldById(fieldChanged)
FormField formSubcomponent = getFieldByName("B")
Object componentFormValue = formComponent.getFormValue()
if(!componentFormValue)
{
return;
}

How to set an option to a multi select version picker ? in the logs i see the values are perfect but the field disappeaars when i select a value from other field

i use below for setting values for single select and multiselect version picker . for single select its working fine .

Map fieldOptions = [:]

fieldOptions.put(vid.toString(), vname)

formSubcomponent.setFieldOptions (fieldOptions)

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.
March 27, 2012

Do you want to set the value (setFormValue()) or set the available options (.setFieldOptions()) for the multi-version picker?

Mizan
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.
March 27, 2012

i want to set the available options (.setFieldOptions()) for the multi-version picker.

And how to clear the values in the fields when i unselect or make the field empty again ? because now when i unselect the option i am able to see the values until i select another option.

Mizan
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.
March 28, 2012

i found that the format in which a single version picker values and multi version picker values are saved is different. a single version requires

fieldOptions.put(vid.toString(), vname)

formSubcomponent.setFieldOptions (fieldOptions)

to set the value.

while, a mulitiversion picker requires only the version id

formSubcomponent.setFormValue(vid.toString())

Now only have to remove values from dependant fields when options in a multi version picker are cleared.

Mizan
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.
March 29, 2012

When i set value to a multiselect version picke using setFormValue() it sets the value perfectly but when i try to set the options of the multiselect version picker using setFieldOptions() the field disappears however when i view the source of the page from the browser i see the options in the field. why the field is not visible ?

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.
March 29, 2012

Sounds like a bug, can you report one please... The fact that you see it in the source doesn't mean much, the javascript manipulates the dom, such that it might have little resemblance to the source.

Mizan
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.
March 29, 2012

Ok , i need to set the multiversion picker options because i cant let it display all the versions of the project.

Mizan
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.
April 1, 2012

Hi Jamie ,

What might be the reason for this behaviour ? i wish this bug gets resolved soon .

TAGS
AUG Leaders

Atlassian Community Events