I have created a custom field in a module. I used the date type but now I have identified that I must use the datetime type since the value to be stored is similar to this 2022-05-20T14:11:46Z
In study I can confirm that it is not allowed to change the data type.
Right now it is not a problem to delete it but I wanted to know what is the way to do it because I might need the same thing in another scenario. I also wanted to avoid creating a table *_cstm when creating a new field
You can change it in the vardefs, and then in the QR&R you would get a button to execute a SQL query that would change the DB. But this can get tricky if there is already data there…
It’s possibly that one, I don’t know for sure. I would say it is whichever file has your field definition in it, and is not a file generated by a QR&R (the ones with paths including /Ext/).
Hi, the type of a custom field created in studio is saved in the table fields_meta_data
To convert the field it would be helpful if you create a new field with the type and desired configuration, as the fields “ext1”, "ext2, “ext3”, “ext4” contain specific configuration details depending in which field type you configure.
In case you want to create a custom field which contents is not saved in a _cstm table, but in the same table where the standard fields of the module are saved, then you’d have to set it up by creating a vardef file, which should probably be saved in (name of the file you can decide for yourself) public/legacy/custom/Extension/modules/sonar_sale/my_special_field.php
with contents something like in the following post (first file):
Please note you have to prepend public/legacy/ in the file paths for Suitecrm 8.
To get an idea what you need to define as vardefs, you can also create a module in ModuleBuilder with the field you want, then publish the module and analyze its contents
Hi there,
I have solved the similar goal.
With the field type number I forced to change it to string.
The reason was that the environment is changed and now I need ‘0’ zeroes before the number what is impossible with the field with number type.
Addon:
I try to avoid direct changing of Vardefs files if it is possible. I have sync issue before when configuration doesn’t work properly after changes. Maybe database and configuration into files are not synced well. To avoid it I prefer to use Studio mostly. To find out the reason it takes too much time and often leads to restore backup.
I have found 2 solutions to avoid data loss:
With SQL if you have the access to data base.
1.1. Write sql query to select, process and then update new field data .
With SuiteCRM Workflow tools only.
2.1 add the new field with Studio
2.2 use Workflow to populate new field with some changes using Calculated Fields.
Warning!!! The biggest problem here is the issues of String functions in Calculated Fields of the SuiteCRM Workflows.
Fore example I can’t add zero symbols. Even you operate with strings when you try to put zero before a numbers the function cut zeros ahead of the first number.
The same problem with space symbols. I didn’t find how to change in Calculated Fields any symbol to ‘space’.
Hide or remove old field.
The result - I used SQL query.