SuiteCRM 填充相关字段

时间:2021-05-28 18:42:29

标签: sugarcrm suitecrm auto-populate

在商机模块编辑视图中,选择联系人(相关字段)时,我需要自动填充帐户名称(相关字段)。 我可以填写联系人和帐户名称编辑框,并且只能填写一个 ID。 这意味着我可以设置联系人或帐户名称,但不能设置他们的摊位。

有人可以帮忙吗?

    array (
      0 => 
      array (
        'name' => 'kontakt_c',
        'studio' => 'visible',
        'label' => 'LBL_KONTAKT',
        'displayParams' => array (
            'field_to_name_array' => array(     
                'id' => 'contact_id_c', 
                'name' => 'kontakt_c',
                'account_name' => 'account_name',
                'account_id' => 'account_id',
                ),
         ),
      ),
      1 => 
        array (
            'name' => 'account_name',
            'studio' => 'visible',
        )
    ),

1 个答案:

答案 0 :(得分:0)

我更喜欢使用自定义视图,在那里引入您可能需要的任何 javascript 代码。

首先在 custom/modules/Contacts/views/view.edit.php 中构建自定义视图:

<?php

require_once 'modules/Contacts/views/view.edit.php';

class CustomContactsViewEdit extends ContactsViewEdit
{
    public function __construct()
    {
        parent::__construct();
        $this->useForSubpanel = true;
        $this->useModuleQuickCreateTemplate = true;
        // Since the suite base modules name the bean in the singular, we configure in the view the name of the module in the plural. This property will be used by the SticViews class to load the language files
        $this->moduleName = 'Contacts';
    }

    public function preDisplay()
    {
        parent::preDisplay();


        // Write here you custom code
    }

    public function display()
    {
        parent::display();

        echo '<script type="text/javascript" src="custom/modules/Contacts/CustomUtils.js"></script>';
    }
}

然后你构建你的 javascript 文件 custom/modules/Contacts/CustomUtils.js 引入你可能需要的代码。

如果你不需要它是即时的,你也可以使用一个逻辑钩子 before_save 并分别在那里分配帐户/联系人。

相关问题