Multiselect dependent or add fields button

Hi to all,
based on the following link:
https://suitecrm.com/forum/developer-help/828-dynamic-multiselect

i would like to impement something like that but with 2 multiselect fileds(the last one must depends on the first one).

I saw a lot of discussion on it and i donā€™t really understand if its achieveable or not.

Another possible solution could be to have 1 parent single dropdown list that drives the second multiselect (exactly like the link above).
The only difference could be the possibility to add multiple filed just like when you add condition or actions in the workflow.

To clarify:
parent dropdow -> products(laptops, workstations)
child multiselect -> types (laptops-a, laptops-b,workstations-a, workstations-b)

in editview i select from products ā€œlaptopsā€ and in the type multiselect field i should select only ā€œlaptops-a or laptops-b or bothā€.
Then clicking on a ā€œ+ā€ button i would add a new selection for products and types.
Anyone could point me on the right way?

Thank you

HI rainolf,

Best way to achieve this to use jquery, what i preferred.

Follow this,

First drop down,

 <select id="1st"> 
  <option value="">Select Type</option>
  <option value="a">a</option>
 <option value="b">b</option>
 <option value="c">c</option>
 </select>

Second drop down,


<select id="2nd"> 
  <option value="">Select Type</option>
  <option value="a_x">x</option>
  <option value="a_y">y</option>
  <option value="a_z">z</option>
 <option value="b_p">p</option>
 <option value="b_q">Q</option>
 </select>
Jquery is here,
$('#1st').change(function(){
    var e = this.value;         
    $("#2nd > option").show();
    $("#2nd > option:not([value^=\""+e+"\"])").hide();
    $("#2nd").val($('#2nd>option:visible:first').val());
});

your mission will be achievedā€¦

Hi jaydeep,
thank you for your quick reply.

Let me ask you something more in order to have a clear understanding.

1 - the code you wrote are related to both multiselect fields?
2 - the jquery library inclusion are already present in SuiteCRM code or must be downloded and included(in that case where mut be placed)?
3 - this is my first experience in coding around SuiteCRM so could you point me where must i have to place the code above?
4 - the code code abive must be hardcoded or i need first to create fields in studio?
5 - is this customization upgrade safe?

Thank you very much for all

Regards

1 - the code you wrote are related to both multiselect fields?
Yes it is. But you need to use for each loop for multipule select.
2 - the jquery library inclusion are already present in SuiteCRM code or must be downloded and included(in that case where mut be placed)?
Jquery libraray is already present.No need to download anything.
3 - this is my first experience in coding around SuiteCRM so could you point me where must i have to place the code above?
include the .js file in these two following files only.
You need to use customcode in editviewdefs.php (if u want in edit page).
You need to use customcode in searchviewdefs.php (if u want in search page).
4 - the code code abive must be hardcoded or i need first to create fields in studio?
You need to hardcode it. studio wonā€™t work here.
5 - is this customization upgrade safe?
Indeed it is upgradesafe

Hi jaydeep,
thank you for your help.

I will try the code and let you know.

Hope ti disturb you again for any further doubts.

Thans again

Hi jaydeep,
my apologies.

Starting to develop iā€™ve realized that i need to understand better how SuiteCRM works.

My questions are:
Can u point me on a developer guide useful to start with it?
Just to understand the logic behind:

  • the dropdown code must be wrote in the same js or where?
  • have i to first create fields in studio or not?
  • could you provide me a valid example?

Thank you

Just to descibe you better iā€™ve made a test.

Iā€™ve created one field in studio with js inclusion and the result in ediviewdefs is:

ā€˜LBL_PANEL_ADVANCEDā€™ =>
array (
0 =>
array (
0 => ā€˜statusā€™,
1 => ā€˜lead_sourceā€™,
),
1 =>
array (
0 =>
array (
ā€˜nameā€™ => ā€˜status_descriptionā€™,
),
1 =>
array (
ā€˜nameā€™ => ā€˜lead_source_descriptionā€™,
),
),
2 =>
array (
0 => ā€˜opportunity_amountā€™,
1 => ā€˜refered_byā€™,
),
3 =>
array (
0 => ā€˜campaign_nameā€™,
),
4 =>
array (
0 =>
array (
ā€˜nameā€™ => ā€˜dbg_custom_service_type_cā€™,
ā€˜studioā€™ => ā€˜visibleā€™,
ā€˜labelā€™ => ā€˜LBL_DBG_CUSTOM_SERVICE_TYPEā€™,
),
),
),
ā€˜includesā€™ =>
array (
0 =>
array (
ā€˜fileā€™ => ā€˜custom/modules/Leads/dbg_custom_leads.jsā€™,
),
),

Then iā€™ve created for test dbg_custom_leads.js like this:

//Alert on Change:
$(function() {

    $('#dbg_custom_service_type_c').on('change', function() {
        alert("Changed!!!");

});

});

When i try to select one item in the field nothing happens, firebug also doesnā€™t show me any action triggered.

Thank you

Anyone can help me?

Maybe i need to include ta before?

Thank you

Hi rainolf,

Any JS error displayed ?

OR

Try following.

$(document).ready(function(){

$(ā€™#dbg_custom_service_type_cā€™).change(function(){

alert(ā€˜Event Firedā€™);

});

});

Quick Repair and Rebuildā€¦

Hope this helpsā€¦