{"id":8687,"date":"2024-07-10T06:18:44","date_gmt":"2024-07-10T06:18:44","guid":{"rendered":"https:\/\/www.infinitivehost.com\/knowledge-base\/?p=8687"},"modified":"2024-08-23T08:14:19","modified_gmt":"2024-08-23T08:14:19","slug":"create-custom-module-in-vtiger-crm-step-by-step-guide","status":"publish","type":"post","link":"https:\/\/www.infinitivehost.com\/knowledge-base\/create-custom-module-in-vtiger-crm-step-by-step-guide\/","title":{"rendered":"Create Custom Module in Vtiger CRM: Step-by-Step Guide"},"content":{"rendered":"<div class='epvc-post-count'><span class='epvc-eye'><\/span>  <span class=\"epvc-count\"> 3,685<\/span><span class='epvc-label'> Views<\/span><\/div>\n<p class=\"wp-block-paragraph\">Creating a custom module in vTiger CRM from scratch involves several steps, including defining the database schema, creating the necessary files, and installing the module. Here is a detailed guide to help you create a custom module with its own table.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Step 1: Set Up Your Environment<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Backup<\/strong>: Take a backup of your current vTiger instance, including the database.<\/li>\n\n\n\n<li><strong>Environment<\/strong>: Ensure you have a working vTiger CRM instance and access to the server.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 2: Define the Database Schema<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create Tables<\/strong>: Create the necessary tables in the database for your custom module. For example, if your module is named &#8220;CustomModule&#8221;, you might create two tables: <code>vtiger_custommodule<\/code> and <code>vtiger_custommodulecf<\/code>.<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">CREATE TABLE `vtiger_custommodule` (\n  `custommoduleid` int(11) NOT NULL AUTO_INCREMENT,\n  `customfield` varchar(255) NOT NULL,\n  PRIMARY KEY (`custommoduleid`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;\n\nCREATE TABLE `vtiger_custommodulecf` (\n  `custommoduleid` int(11) NOT NULL,\n  PRIMARY KEY (`custommoduleid`)\n) ENGINE=InnoDB DEFAULT CHARSET=utf8;<\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 3: Create the Basic Structure<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Folder Structure<\/strong>: Navigate to the <code>modules<\/code> directory in your vTiger installation and create a new folder for your custom module. For example, create a folder named <code>CustomModule<\/code>.<\/li>\n\n\n\n<li><strong>Module File<\/strong>: Inside your <code>CustomModule<\/code> folder, create a file named <code>CustomModule.php<\/code>. This file will contain the class for your module.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 4: Define the Module Class<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">In <code>CustomModule.php<\/code>, define your module class:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;?php\n\ninclude_once 'modules\/Vtiger\/CRMEntity.php';\n\nclass CustomModule extends CRMEntity {\n    public $table_name = 'vtiger_custommodule';\n    public $table_index= 'custommoduleid';\n\n    \/\/ Define the mandatory table for supporting custom fields.\n    public $customFieldTable = Array('vtiger_custommodulecf', 'custommoduleid');\n\n    \/\/ Define the list of tables related to this module.\n    public $tab_name = Array('vtiger_crmentity', 'vtiger_custommodule', 'vtiger_custommodulecf');\n\n    public $tab_name_index = Array(\n        'vtiger_crmentity' =&gt; 'crmid',\n        'vtiger_custommodule' =&gt; 'custommoduleid',\n        'vtiger_custommodulecf'=&gt;'custommoduleid'\n    );\n\n    public $list_fields = Array (\n        'Custom Field' =&gt; Array('custommodule', 'customfield'),\n        'Assigned To' =&gt; Array('crmentity','smownerid')\n    );\n\n    public $list_fields_name = Array (\n        'Custom Field' =&gt; 'customfield',\n        'Assigned To' =&gt; 'assigned_user_id'\n    );\n\n    public $list_link_field = 'customfield';\n\n    public $search_fields = Array(\n        'Custom Field' =&gt; Array('custommodule', 'customfield')\n    );\n\n    public $search_fields_name = Array (\n        'Custom Field' =&gt; 'customfield'\n    );\n\n    public $popup_fields = Array ('customfield');\n\n    public $def_basicsearch_col = 'customfield';\n\n    public $def_detailview_recname = 'customfield';\n\n    public $mandatory_fields = Array('customfield', 'assigned_user_id');\n\n    public $default_order_by = 'customfield';\n    public $default_sort_order='ASC';\n}\n?&gt;<\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 5: Create the Installation Script<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Create an installation script to register your module. Create a file named <code>manifest.xml<\/code> in the <code>CustomModule<\/code> directory:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code><mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-red-color\">&lt;?xml version=\"1.0\"?&gt;\n&lt;module&gt;\n    &lt;name&gt;CustomModule&lt;\/name&gt;\n    &lt;label&gt;Custom Module&lt;\/label&gt;\n    &lt;parent&gt;Tools&lt;\/parent&gt;\n    &lt;version&gt;1.0&lt;\/version&gt;\n    &lt;type&gt;entity&lt;\/type&gt;\n    &lt;php_version&gt;5.2&lt;\/php_version&gt;\n    &lt;dependencies&gt;\n        &lt;vtiger_version&gt;7.0&lt;\/vtiger_version&gt;\n    &lt;\/dependencies&gt;\n    &lt;tables&gt;\n        &lt;table&gt;\n            &lt;name&gt;vtiger_custommodule&lt;\/name&gt;\n            &lt;engine&gt;InnoDB&lt;\/engine&gt;\n            &lt;fields&gt;\n                &lt;field&gt;\n                    &lt;name&gt;custommoduleid&lt;\/name&gt;\n                    &lt;type&gt;int&lt;\/type&gt;\n                    &lt;nullable&gt;false&lt;\/nullable&gt;\n                    &lt;key&gt;PRI&lt;\/key&gt;\n                    &lt;extra&gt;auto_increment&lt;\/extra&gt;\n                &lt;\/field&gt;\n                &lt;field&gt;\n                    &lt;name&gt;customfield&lt;\/name&gt;\n                    &lt;type&gt;varchar&lt;\/type&gt;\n                    &lt;nullable&gt;false&lt;\/nullable&gt;\n                    &lt;length&gt;255&lt;\/length&gt;\n                &lt;\/field&gt;\n            &lt;\/fields&gt;\n        &lt;\/table&gt;\n        &lt;table&gt;\n            &lt;name&gt;vtiger_custommodulecf&lt;\/name&gt;\n            &lt;engine&gt;InnoDB&lt;\/engine&gt;\n            &lt;fields&gt;\n                &lt;field&gt;\n                    &lt;name&gt;custommoduleid&lt;\/name&gt;\n                    &lt;type&gt;int&lt;\/type&gt;\n                    &lt;nullable&gt;false&lt;\/nullable&gt;\n                    &lt;key&gt;PRI&lt;\/key&gt;\n                &lt;\/field&gt;\n            &lt;\/fields&gt;\n        &lt;\/table&gt;\n    &lt;\/tables&gt;\n&lt;\/module&gt;<\/mark><\/code><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Step 6: Install the Module<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Upload the Folder<\/strong>: Upload your <code>CustomModule<\/code> folder to the <code>modules<\/code> directory of your vTiger installation.<\/li>\n\n\n\n<li><strong>Install via vTiger<\/strong>: Log in to vTiger as an administrator, go to the Module Management section, and use the &#8220;Import Module&#8221; feature to upload and install your <code>CustomModule<\/code>.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 7: Configure the Module<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Create Fields<\/strong>: Use the Layout Editor in vTiger to add fields to your module as needed.<\/li>\n\n\n\n<li><strong>Permissions<\/strong>: Set permissions for roles to access the new module.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Step 8: Test Your Module<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Verify Installation<\/strong>: Check that the module appears in the CRM and that you can create, view, edit, and delete records.<\/li>\n\n\n\n<li><strong>Debug<\/strong>: If there are any issues, check the <code>vTiger.log<\/code> and <code>PHP error logs<\/code> for troubleshooting.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading\">Additional Customizations<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Depending on your specific requirements, you might need to add more customizations, such as:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Language Files<\/strong>: Create language files to support multiple languages.<\/li>\n\n\n\n<li><strong>Custom Views<\/strong>: Create custom views for list and detail views.<\/li>\n\n\n\n<li><strong>Workflow Integration<\/strong>: Integrate your module with vTiger workflows.<\/li>\n\n\n\n<li><strong>Web Services<\/strong>: Enable web services for your custom module if needed.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">By following these steps, you can create and configure a custom module in vTiger CRM with its own table.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Making the best custom module in vTiger CRM solutions initially from raw consists of numerous steps, consisting of describing the database schema, developing the important documents, and only installing the needed module. Here is a complete guide to help you develop a custom module with its individual table. Infinitive Host provides you the <a href=\"https:\/\/www.infinitivehost.com\/managed-vtiger-solutions\"><strong><mark style=\"background-color:#8ed1fc\" class=\"has-inline-color has-black-color\">best vTiger hosting solutions<\/mark><\/strong><\/a> that easily match your requirements.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>3,685 Views Creating a custom module in vTiger CRM from scratch involves several steps, including defining the database schema, creating the necessary files, and installing the module. Here is a detailed guide to help you create a custom module with its own table. Step 1: Set Up Your Environment Step 2: Define the Database Schema [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[204],"tags":[],"class_list":["post-8687","post","type-post","status-publish","format-standard","hentry","category-vtiger-solutions"],"_links":{"self":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/8687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=8687"}],"version-history":[{"count":2,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/8687\/revisions"}],"predecessor-version":[{"id":8891,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/8687\/revisions\/8891"}],"wp:attachment":[{"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=8687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=8687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.infinitivehost.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=8687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}