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:

<?php

$Vtiger_Utils_Log = true;

include_once('vtlib/Vtiger/Module.php');

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

if ($module)

{

$module->delete();

}

?>

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:

<?php

$Vtiger_Utils_Log = true;

include_once('vtlib/Vtiger/Menu.php');

include_once('vtlib/Vtiger/Module.php');

$module = new Vtiger_Module();

$module->name = 'ModuleName';

$module->save();

$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

$block1->label = 'LBL_MODULENAME_INFORMATION';

$module->addBlock($block1);

$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

$block1->addField($field2);

$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;

$module->addFilter($filter1);

$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

$module->disableTools('Merge');

?>

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.