Leo T Abraham Leo T Abraham - 1 year ago 106
PHP Question

Creating custom module in Vtiger CRM from scratch with table

I am new to Vtiger CRM and I have searched a lot to find how to create a custom module in Vtiger CRM with a table associated with it from scratch. I am not able to follow the documentation provided by Vtiger.

Answer Source

Refer this url for Creating New module and fields.


Or if you having any problem then follow as per instructions.

first of all do this.

First create a new folder(module name without space) in modules and copy files from vtlib/ModuleDir/5.4.0 file to the folder created in modules/newmodule

Change name of ModuleFile.js, ModuleFile.php, ModuleFileAjax.php with your module name(with no space).

Keep in mind, During changing name of ModuleFileAjax.php just Replace ModuleFile with name of Module.

Go to modulename.php to change the class name, $table_name (6values change), $table_index (4values change).

Create new file with any name. Insert the code below to add the fields and also module.


// Turn on debugging level
$Vtiger_Utils_Log = true;

$module = new Vtiger_Module();
$module->name = 'Store';//(No space in module name)


$menu = Vtiger_Menu::getInstance('Support');

$block1 = new Vtiger_Block();
$block1->label = 'Organization Information';
$module->addBlock($block1); //to create a new block

$field0 = new Vtiger_Field();
$field0->name = 'organization_name';
$field0->label = 'Organization Name';
$field0->table = $module->basetable; 
$field0->column = 'organization_name';
$field0->columntype = 'VARCHAR(100)';
$field0->uitype = 2;
$field0->typeofdata = 'V~M';
$module->setEntityIdentifier($field0); //to insert values in entity folder
$block1->addField($field0); //to add field in block

$field1 = new Vtiger_Field();
$field1->name = 'store_id_auto';
$field1->label = 'Store ID';
$field1->table = $module->basetable; 
$field1->column = 'store_id_auto';
$field1->columntype = 'VARCHAR(100)';
$field1->uitype = 4;
$field1->typeofdata = 'V~O';

//Do not change any value for filed2.
$field2 = new Vtiger_Field();
$field2->name = 'assigned_user_id';
$field2->label = 'Assigned To';
$field2->table = 'vtiger_crmentity'; 
$field2->column = 'smownerid';
$field2->columntype = 'int(19)';
$field2->uitype = 53;
$field2->typeofdata = 'V~M';

$filter1 = new Vtiger_Filter();
$filter1->name = 'All';
$filter1->isdefault = true;
// Add fields to the filter created
$filter1->addField($field0, 1);
$filter1->addField($field1, 2);
$filter1->addField($field2, 3);

/** Set sharing access of this module */
/** Enable and Disable available tools */
$module->enableTools(Array('Import', 'Export'));