Change existing enum field to multi enum
Collapse
X
-
I had wondered if that was the case but didnt have chance to check the backend DB. Makes sense. Thanks telecastg
-
FYI enum and multienun are both stored by the database as varchar, but their contents are two different things:
Enum fields are stored as simple varchar value corresponding to the choice selected in the enum field display.
For example, assuming that you have an enum field with the choices: "Option 1", "Option 2" and "Option 3" and you select "Option 3", the varchar field in the table will have the string "Option 3"
Multi-enum fields are stored as an array inside de varchar, with one element for each choice selected in the multi-enum field display.
Asuming that you have a multi-enum field with the same choices as above, and you select "Option 1" and Option 3", the varchar content will be "[Option 1, Option 3]"
Hope this helps clarifying.
Leave a comment:
-
Hey shalmaxb, thanks for the reply, yep I did try a rebuild, the field is just empty after making the change to multienum. It shows correctly in Entity manager as multi-enum, so change has taken effect ok. I guess the format of the object in the backend DB for enum vs multi-enum is different. No worries, I will go with the option of doing export/import.Leave a comment:
-
Hello, I thought i'd give some feedback - i needed to do this for a field and tried it for changing enum to multiEnum for the type field in the Contacts entity, but found that after the change (editing the json), where there had been a value in the Type field this was now blank. So it looks like it does work, but you lose your existing data,
So I can retain the data I'm going to try exporting record ID and the type field, then import back in after the change.Leave a comment:
-
Would you happens to know which type of field is compatibility?
If the field type is the same, I assume it always will work. But certain field must have similar type to use this method.Leave a comment:
-
Happy to let you learn new trick for espocrm,
Yes this trick cannot help for all fields types, -
Yes true. This can be done with similar fields like you said.Never knew about the "remove field name" trick. That is good to know. Adding this to Learning EspoCRM.
But question is, it won't work for all field right? e.g you can't delete a varchar field and create a new intreger field. But something that is similar can be done, e.g. eNum > multiEnum?Leave a comment:
-
Never knew about the "remove field name" trick. That is good to know. Adding this to Learning EspoCRM.
But question is, it won't work for all field right? e.g you can't delete a varchar field and create a new intreger field. But something that is similar can be done, e.g. eNum > multiEnum?Leave a comment:
-
yes it is possible by two ways,
The best is to edit the file manually, you can find the definiation of the field in one of these pathes:- 'corePath' => 'application/Espo/Resources/metadata/entityDefs/YourEntity.json',
- 'modulePath' => 'application/Espo/Modules/{*}/Resources/metadata/entityDefs/YourEntity.json',
- 'customPath' => 'custom/Espo/Custom/Resources/metadata/entityDefs/YourEntity.json',
Or if you dont have access to the files you can remove the field and re-add a new field with THE SAME NAME, espocrm will not remove the column from the database, so that the values will remain with the new field.
Please give me feedback for other usersLeave a comment:
-
Change existing enum field to multi enum
Hi,
Is it possible to change existing enum field to multi enum field ??Tags: None

Leave a comment: