How to restrict to select multiple components?

VenugopalY January 18, 2013

Hi Support,

Please let us know how to limit to select only one component.

Currently system allows to select multiple list of components. How to avoid that and restrict to one.

Venu

1 answer

1 vote
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.
January 18, 2013

You will need a javascript which will check for the number of components selected and restrict the user for entering more than on component. (paste this script in the field description)

This Jtricks tutorial shows how to make the Fix versions field as single picker .You can refer this and get an idea .

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.
January 18, 2013

try pasting the below script in the components field description

<script >
  var formId = AJS.$("#components").closest('form').attr('id');
  AJS.$('#'+formId).submit(function() {
     var count = AJS.$("#components :selected").length;
     if (count > 1){
        alert('You can select only one Component for an issue');
        return false;
     } else {
        return true;
     }
  });
</script>

VenugopalY February 3, 2013

Hi Mizan,

I tried by adding above script under components description. But didn't work. Not sure what is stopping here. Please advise.

Suggest an answer

Log in or Sign up to answer