Convert Dynamic DropDown menu to MultiSelect

Hi,

I have a Dynamic DropDown menu created in Studio, I need to convert it to MultiSelect without loose data. How can I do, editing some files by hand? Which?

Thanks!

Hi

I don’t know the full process for you, but to get you started, look for PHP files under custom which contain strings from your dropdown items.

I would start by searching in custom/include/language/en_us.lang.php

This post will gives you a sample:

Thanks,

BrozTechnologies

Hi,

for fields created with studio the field definitions are not saved in vardefs, but in the database table fields_meta_data.

To convert your field, assuming your field has the name “fieldname_c” and was created for the module “Contacts” you would:

  1. Remove the field from all layouts using studio
  2. Execute the SQL Query to convert the field type:
update fields_meta_data set type='multienum', ext2=NULL where name='fieldname_c' and custom_module='Contacts';
  1. Values for MultiSelect are saved using the caret symbol “^” as limiter and separated by “,” like ‘^option1^,^option2^,^option3^’. To convert the field values accordingly, execute the SQL Query:
update contacts_cstm set fieldname_c = concat('^', concat(fieldname_c, '^'));
  1. In SuiteCRM, do a Admin -> Repair -> Quick Repair and Rebuild
  2. Add the field to the layouts again

Please note that this multiselect is no longer dynamic: its values do no longer depend on a parent dropdown field.

1 Like

Thanks jansiero!

Is it really necessary to “Remove the field from all layouts using Studio”? I remember that in my case it is a “Dynamic DropDown” which will be converted to MultiSelect (it doesn’t matter if I lose “depend on a parent dropdown field”).

Hi @harry84, yes, because the field type is also saved in the view definitions, so to make sure that it is displayed as a multiselect, you will have to remove it and add it again.

You could also edit the custom/modules/<module>/metadata/*viewdefs.php files to change the field type, but removing and adding them through studio is less error prone.

Thanks @jansiero, great help!

@jansiero

I just had time to make the changes, I just wanted to say that after getting to point 4) In SuiteCRM, I give to Admin -> Repair -> Quick Repair and Rebuild, I realized that in listviewdefs.php there was the field that I was converting set as dynamicenum, and then either edited that word in multienum and did a Quick Repair and Rebuild again, performed step 5, Quick Repair and Rebuild and everything seems OK.

I wanted to know if I was right to edit listviewdefs.php by hand.

Hi @harry84,

Yes, that’s correct. nice to read that you solved your issue.