Creating or Deleting a Related List in vTiger CRM:-
“More Information” tab in the Detail View of record associates one particular module with multiple records of any other module.
How to create a New Related ListView:-
<?php
include_once('vtlib/Vtiger/Module.php');
//Where you want to add the realted module.
//Source Module Name
$moduleInstance = Vtiger_Module::getInstance('Products');
//Target Module Name
$targetModule = Vtiger_Module::getInstance('Vendors');
//Target Module Relationship Label.
$relationLabel = 'Vendors';
//call back function name.
$function_name = 'get_vendors';
//Create a relation ship.
$moduleInstance->setRelatedList($targetModule, $relationLabel, Array('ADD','SELECT'),$function_name);
?>
(Note: Take the code above to any text editor and name it to ‘Related_moduleName.php’ while saving and save it under root directory of vtigerCRM. After saving run this file on server (either localhost or your own server) which will add UI under source module. ModuleName referred above is the name of module.)
This function stated above is to be defined in <SOURCE MODULE> class and will generate the entries of listview to be displayed. In addition to this an entry in ‘vtiger_crmentityrel’ table will be made which will track the relation between all the modules and their corresponding records. All primary modules in vTigerCRM handles relation in tables separately and undergo JOIN which fetching the data specific to every module.
Delete the Related ListView:-
<?php
include_once('vtlib/Vtiger/Module.php');
//Where you want to add the realted module.
//Source Module Name
$moduleInstance = Vtiger_Module::getInstance('Products');
//Target Module Name
$targetModule = Vtiger_Module::getInstance('Vendors');
//Target Module Relationship Label.
$relationLabel = 'Vendors';
//call back function name.
$function_name = 'get_vendors';
//Delete a relation ship.
$moduleInstance->unsetRelatedList($targetModule,$relationLabel,$function_name);?>