vTiger - How to use module field in another module

2019-05-28 18:32发布

问题:

I'm newbie in vtiger. I'm trying to insert the field "Service Name" from Services module in TroubleTicket module, but up to now I wasn't able to do it.
Generally speaking, is it possible to insert a field in a Module from another module? If so, how is it supposed to be done?

回答1:

You can use this Code, Put this under your vTiger root directory and call it from browser.

<?php
$Vtiger_Utils_Log = true;

include_once('vtlib/Vtiger/Menu.php');
include_once('vtlib/Vtiger/Module.php');

$module = Vtiger_Module::getInstance('HelpDesk');
if($module) {
$blockInstance = Vtiger_Block::getInstance('LBL_TICKET_INFORMATION', $module);

    if($blockInstance) {

    $fieldInstance = Vtiger_Field::getInstance('Service1', $module);

       if(!$fieldInstance) {
           $fieldInstance = new Vtiger_Field();
           $fieldInstance->name = 'Service1';
           $fieldInstance->label = 'Service Name';
           $fieldInstance->uitype = 10;
           $fieldInstance->typeofdata = 'V~O';
           $blockInstance->addField($fieldInstance);

           $fieldInstance->setRelatedModules(Array('Services'));
       }
  }
}
?>



标签: vtiger