How can I change the data type of a custom field?

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.

image

Can you just delete the field and create a new one? Are you worried about losing data already inserted?

Hello. Thanks for answering.

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…

Would this be the file to modify?

public/legacy/modules/sonar_sale/vardefs.php

It is that it is a custom module and it does not have a directory in custom/modules for it.

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

Thanks the information works for me