Tuesday, May 14, 2013

Related List in vTiger CRM



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);?>


3 comments:

  1. when I create the relationship appears to me the label of the report but I do not automatically adds links when I believe a new record to be inserted, in my case I create the relationship between accounts and domains, I think when I connect it with a new domain accounts but if I go see accounts you see the label of the empty domain

    ReplyDelete
  2. Can you please add the link or some more explain ?

    ReplyDelete
  3. vTiger CRM is already well-appointed with leading results, best marketing management, and end-to-end sales and automation tools. Email campaigns will add another level of depth to Vtiger’s customer nurturing capabilities and providing with the best services it can help to make your business reap best results using or applying the features in an appropriate way.

    ReplyDelete