【问题标题】:How to create custom field in contact module in vtiger CRM如何在 vtiger CRM 的联系人模块中创建自定义字段
【发布时间】:2020-08-13 16:01:27
【问题描述】:

我使用互联网编写了这段代码,但它不起作用。我将此文件保存在根目录中。我需要在联系人模块中创建一个必填字段和下拉字段。

<?php

$Vtiger_Utils_Log = true;
ini_set('error_reporting', E_ALL);
ini_set('display_errors', '1');
include_once('../../config.inc.php');
set_include_path($root_directory); //for include root path
include_once('vtlib/vtiger/menu.php');
include_once('vtlib/Vtiger/Module.php');
include_once('vtlib/Vtiger/Block.php');



$moduleInstance = Vtiger_Module::getInstance('Contacts');//Module Name
$blockInstance = Vtiger_Block::getInstance('LBL_CONTACT_INFORMATION', $moduleInstance);//Block Name


$fieldInstance = new Vtiger_Field();
$fieldInstance->name = 'whatsapp';
$fieldInstance->label = 'LBL_WHATSAPP';
$fieldInstance->table = 'vtiger_contactdetails';
$fieldInstance->column = 'whatsapp';
$fieldInstance->columntype = 'varchar(11)';
$fieldInstance->uitype = 1;
$fieldInstance->typeofdata = 'V~O';
$blockInstance->addField($fieldInstance);
$fieldInstance->setRelatedModules(array('Accounts'));

?>

【问题讨论】:

    标签: php crm vtiger vtigercrm dynamic-picklist-vtiger


    【解决方案1】:

    您的代码看起来不错,我建议您在创建字段之前检查模块并阻止存在。你确定你的数据库连接正常吗?日志文件夹显示没有错误?

    这就是我添加字段的方式。

    <?php
    
    $Vtiger_Utils_Log = true;
    ini_set('error_reporting', E_ALL);
    ini_set('display_errors', '1');
    include_once('../../config.inc.php');
    set_include_path($root_directory); //for include root path
    include_once('vtlib/vtiger/menu.php');
    include_once('vtlib/Vtiger/Module.php');
    include_once('vtlib/Vtiger/Block.php');
    
    
    
    $moduleInstance = Vtiger_Module::getInstance('Contacts');//Module Name
    if($moduleInstance){
        $blockInstance = Vtiger_Block::getInstance('LBL_CONTACT_INFORMATION', $moduleInstance);//Block Name
    
        if($blockInstance){
            $fieldInstance = Vtiger_Field::getInstance('whatsapp', $moduleInstance);
            if(!$fieldInstance){
                $fieldInstance = new Vtiger_Field();
                $fieldInstance->name = 'whatsapp';
                $fieldInstance->label = 'LBL_WHATSAPP';
                $fieldInstance->table = 'vtiger_contactdetails';
                $fieldInstance->column = 'whatsapp';
                $fieldInstance->columntype = 'varchar(11)';
                $fieldInstance->uitype = 1;
                $fieldInstance->typeofdata = 'V~O';
                $blockInstance->addField($fieldInstance);
                $fieldInstance->setRelatedModules(array('Accounts'));
            }
            else{
                echo "field already present";
            }
        }
        else{
            echo "no block";
        }
    }
    else{
        echo "no module";
    }
    
    ?>
    

    【讨论】:

    • 感谢您的回答,我使用运行脚本完成了。
    【解决方案2】:

    如果您需要 VTiger 开源平台的在线帮助,我建议您访问 Telegram 论坛。 https://t.me/vtiger7crm

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多