[Vtigercrm-developers] edit field type

Alan Lord alanslists at gmail.com
Thu Oct 8 07:28:45 GMT 2015

On 07/10/15 18:57, lucia digirolamo wrote:
> Hi,
> A while ago I created a custom field for my Organizations module to hold
> the vat number. Now I just realized that this custom field does not keep
> the leading zeros. I don't remember what type I used, probably integer,
> since vat number contains no letters, but surely is not a text type,
> because I creating a new text field for testing purpose and if I enter
> here a number starting with zero, the zero is kept. But I cannot simply
> delete the existing field and substitute it with a new text field
> because if I do I would lose all the data that have been already
> inserted. So I have to change the type of this custom field from
> whatever it is now (that doesn't keep zeros) to a text field (which
> keeps zeros).

You can do the following (work on a backup system first if you are 
unsure what your doing)

Change the UIType in vtiger field...

If your field is called cf_123 then edit the row in vtiger_field where 
the fieldname = cf_123 and change the UIType from 7 (or whatever it is) 
to 1.

You might also need to review the information in the typeofdata column 
too. You probably want something like N~O (or even maybe I~O). Try 
making some changes and see how it affects your ability to populate the 

Find the column of the real field in the database. If your field is 
called cf_123 and it is for the Organization module then in the table 
vtiger_accountscf will be a column called cf_123.

Look at the structure of that column and see if you need to change it. 
You can change some types such as from INT or DECIMAL() to VARCHAR() but 
it might not work the other way around.

You probably want it to be type VARCHAR if it needs to store leading 
zeros. INT, by definition, cannot.



More information about the vtigercrm-developers mailing list