crmvtigervtigercrm

How to add relationship in vtiger 7 custom module


My VTiger custom module is showing nothing in Relationships tab. How i can add relationship to other modules e.g Leads.

I've created the module using console.php

Thanks


Solution

  • Here first method using PHP code.

    Create a php file into your root dir of vtiger as create_relation.php.

    <?php
    /*
    create_relation.php
    Create this file into your root directory of vtiger i.e. vtigercrm/
    and then run this file directly using your browser 
    for example localhost/vtigercrm/create_relation.php
    */
    include_once('vtlib/Vtiger/Module.php');
    $moduleInstance = Vtiger_Module::getInstance('Leads');
    $accountsModule = Vtiger_Module::getInstance('new_module');
    $relationLabel  = 'New_modules';
    $moduleInstance->setRelatedList(
          $accountsModule, $relationLabel, Array('ADD') //you can do select also Array('ADD','SELECT')
    );
    
    echo "done";
    

    Using this vtiger_relatedlists table, relationships are being established

    Read the comments on above code and also update the DB table vtiger_relatedlists if needed. This is the table where you have to make sure the relationfieldid field (column) correct there in this table(vtiger_relatedlists).