Archive for the ‘vTiger’ Category

Problem displaying picklist values in vTiger

A lot of people opt for vTiger as their CRM only because it is Free and Open Source but they just discontinue using vTiger because of its minuscule support and even if they Google their problem then there are number of other developers having the same problem unresolved. For the past few days i was facing a similar problem which i think was merely unattended on vTiger forums or on any other CRM blogs. Problem was that “When we created a module (both back-end & front-end) then after selecting it in menu assigned we found that the assigned values of the Picklist were not being revealed by the Picklist Editor”. I will try to explain the solution to this problem step by step so that it saves someone else’s time. The problem is mainly due to the configuration while creating the module(The Module creation file). In the meantime do checkout an extensive post on Open Source CRM You may need to delete the module in case you have created a custom module. It can be done with the help of following code:


$Vtiger_Utils_Log = true;


$module = Vtiger_Module::getInstance('ModuleName');

if ($module)





Here ‘ModuleName’ depicts the name of your module. Copy this code to any text editor and then save file with name ‘Delete_ModuleName.php’. Once created run this file on your webserver. Once done with this go to your module creation file where we’ll resemble the following format:


$Vtiger_Utils_Log = true;



$module = new Vtiger_Module();

$module->name = 'ModuleName';


$module->initTables();                                     // Initialize all the tables required

$module->initWebservice();                    // Creates a entry in vtiger_ws_entity

$menu = Vtiger_Menu::getInstance('Tools');        // Add the module to the Menu       $menu->addModule($module);

$block1 = new Vtiger_Block();                                    // Add the basic module block



$field1 = new Vtiger_Field();                             //Create fields and add to the module

$field1->name = 'name';

$field1->label = 'Name';

$field1->table = $module->basetable;

$field1->column = 'name';

$field1->columntype = 'VARCHAR(255)';

$field1->uitype = 2;

$field1->typeofdata = 'V~M';                                     // Varchar~Mandatory

$block1->addField($field1);                     // Creates the field and adds to block

$module->setEntityIdentifier($field1);       // Set at-least one field to identifier of module

$field2 = new Vtiger_Field();

$field2->name = 'type';

$field2->label = 'Type';

$field2->table = $module->basetable;

$field2->column = 'type';

$field2->columntype = 'VARCHAR(100)';

$field2->uitype = 15;

$field2->typeofdata = 'V~O';                                     // Varchar~Optional


$field2->setPicklistValues( Array ('Employee', 'Trainee') );         // Picklist values are set

// Common fields that should be in every module, linked to vtiger CRM core table

/**Common fileds that have to be incorporated are:

* assigned_user_id

* createdtime

* modifiedtime


$filter1 = new Vtiger_Filter();                                     // Create default custom filter

$filter1->name = 'All';

$filter1->isdefault = true;


$filter1->addField($field1);                                         // Add fields to the filter created

$filter1->addField($field2, 1);

$filter1->addField($field3, 2);

$module->setDefaultSharing('Public_ReadWrite'); / Set sharing access of this module

$module->enableTools(Array('Import', 'Export'));           //Enable and Disable available tools



Points to be taken care of while creating the ‘vtlib module creation file': 1)       Check your vtlib script for the line “$module->initWebservice()”  as it creates entry in vtiger_ws_entity. 2)       “$module->setEntityIdentifier”    must be set at least once for the mandatory field of the module. 3)       While creating field for picklist do ensure that it refers to “$module->basetable” as without it the picklist values will enter the database but won’t be called in UI. This problem was rampant in the default ‘Payslip’ module creation file as its picklist field expunged this table declaration. After formulating this backend and executing we are left with frontend of our module (modules/ModuleName) and all the files of frontend following it. Now in the file naming ‘ModuleName.php’ we have:

var $list_fields = Array ();

var $list_fields_name = Array();

Here we have to add each and every field (in the format assigned) we have declared in ‘vtlib creation file’ to be listed in UI. Following the above steps can help you eradicated deadly errors with picklist values. Please comment in the blog post if you still face issues and we would be happy to help.

Creating new fields in a vtiger module

Recently, I got stuck with the help on how to create new fields in vtiger since vtiger has only a small community and its very difficult to find help online, I decided write a post so that someone else’s time can be saved. To add a field to an existing module, Follow the following steps:
  • Go to Settings>custom Fields>
  • Select the Module for which you want to create new fields
  • Click on Add New field option
  • Add Label name for the field
  • Select the Field Type
And you are done !!! In case your field is of the type picklist, then you would need to add the picklist values as well. Note that the above procedure will add the field to the current vtiger installation only. In case you want that the field to be budled with a vtiger installation, then you would need to do a bit of php. Fields in modules are controlled by the vtiger_field table – the field must exist in the appropriate database table, and there must be a record in vtiger_field that describes the field.
<pre>$this->db->query("insert into vtiger_field values ( <tabid>,
Here is an overview of what each of the columns mean:
Field Description Allowed Values
tabid ID number of the module (from vtiger_tab) INT, tabid types
fieldid ID of field; generated by getUniqueID(“vtiger_field”). Normally obtained at installation. INT
columnname Name of the column in its table any
tablename Name of the table that stores field any table
generatedtype Specifies type of field in module whether 1=’Exisiting’ or 2=’User Defined’ 1,2
uitype Handles what widget displays field Ui types
fieldname The vTiger name of the field ??
fieldlabel The label name of the field vTiger will look for fieldlabel as a key in the the $mod_strings array stored at modules/ModuleName/language/<language prefix>.lang.php
readonly 0=true(ro) 1=false(rw) BOOLEAN
presence represent the field existence 1 to reprsent existence and 0 to represent non-existence
selected ?? ??
maximumlength ?? ??
sequence The display order of your field in your block. Number (1,2,3…)
block Block id (from Vtiger blocks) where the field will appear INT
displaytype Indicates if field will be displayed on Create/Edit & Detail View. 1=displayed on all views, 2=displayed only in detail view (but not in edit), 3=field will not come separately, it will come along with other field, 4= only in the createview. it will not come other views(detailview & editview) 1,2,3,4
typeofdata X~Y, where X is the type of data V for varchar, N for numbers etc and Y stands for (O)ptional or (M)andatory INV…~OM
quickcreate if field appears or not on quickcreate field 0/1
quickcreatesequence sequence of field in quick create screen number
info_type ‘BAS’ field is displayed in Basic Information, ‘ADV’ field is displayed in More information BAS or ADV
masseditable and helpinfo are the two new fields introduced in the latest version of vtiger(5.1.0 as i write the post). masseditable tells whether the field is masseditable or not. helpinfo lets you specify the helper text for the field(tooltip in this case). Right now(as of version 5.1.0), there is a problem with helpinfo field that it supports only one value and its not possible to localize the string. The following is an example query to add a new field called as website to a new module called as Vendors:

$this->db->query("insert into vtiger_field values (18,".$this->db->getUniqueID("vtiger_field").",'website','vtiger_vendor',1,'17',


You will need to add this query to modules/Users/DefaultDataPopulator.php to bundle the above field with a fresh vtiger installation. And thats all that you need to do to add a new field to a vtiger instance. Please let me know if any queries and we would be happy to answer.

Changing the date format in vTiger

Since 4.0.1, vTiger has added the capability to support the multiple date formats. However, the date format should be set on per user basis. To Change the data format in vTiger CRM, follow the following steps: 1. Login to vtiger CRM 2. Click the My Account link 3. In User account page click the Edit button. 4. In User account page select the required date format from Date Format drop down list. [Edit for vTiger v5.1.0] The above technique no longer applies to the vTiger 5.1.0. To change the Date format in vTiger 5.1.0, please follow the following steps(Assuming a raw vTiger install without any customizations, Please note that the date formatting is still on per user basis):
  • Goto Settings -> Settings
  • Click on the Users
  • Click on the edit icon for User that you want to change the date format for.
  • In the More information, there will be a drop down listing various formats for the date.
  • Chose the date format that you want for this user and you are all done !!!
Hope this helps some one !!