sugarcrm - 广告系列和产品模板之间的自定义多对多关系子面板

标签 sugarcrm

我正在运行 6.5.8 Enterprise,并且一直在为此苦苦挣扎。

我需要与营销事件和产品模板建立多对多关系。然而,工作室似乎只能管理一对一。我的关系似乎还不错,但似乎无法让子面板正常工作。

我做了以下事情:

1: 在 custom/extension.application/ext/tabledictionary/campaigns_producttemplates.php 中添加引用:

include('custom/metadata/campaigns_producttemplatesMetaData.php');

2: 将以下内容放入上面引用的文件中:

<?php// created: 2015-04-10 14:19:05
$dictionary["campaigns_producttemplates"] = array ( //The table name
  //'true_relationship_type' => 'many-to-many', //Relationship type
  'relationships' => 
  array (
    'campaigns_producttemplates' =>  //table name
    array (
      'lhs_module' => 'Campaigns', //Module name as per directory
      'lhs_table' => 'campaigns', //Table Name
      'lhs_key' => 'id', //should be id
      'rhs_module' => 'ProductTemplates', //Module name as per directory
      'rhs_table' => 'product_templates', //Table Name
      'rhs_key' => 'id', //should be id
      'relationship_type' => 'many-to-many', //Relationship type
      'join_table' => 'campaigns_producttemplates',//Table name
      'join_key_lhs' => 'campaign_id', //ID reference of the left side module 
      'join_key_rhs' => 'product_template_id', //ID reference of the right side module
    ),
  ),
  'table' => 'campaigns_producttemplates', //table name
  'fields' => 
  array (
    0 => 
    array (
      'name' => 'id', //ID is needed as a unique id
      'type' => 'varchar',
      'len' => 36,
    ),
    1 => 
    array (
      'name' => 'date_modified', //Required
      'type' => 'datetime',
    ),
    2 => 
    array (
      'name' => 'deleted', //Required
      'type' => 'bool',
      'len' => '1',
      'default' => '0',
      'required' => true,
    ),
    3 => 
    array (
      'name' => 'campaign_id', //Referenced as the above left key
      'type' => 'varchar',
      'len' => 36,
    ),
    4 => 
    array (
      'name' => 'product_template_id', //Referenced as the above right key
      'type' => 'varchar',
      'len' => 36,
    ),
  ),
  'indices' => 
  array (
    0 => 
    array (
      'name' => 'campaigns_producttemplatesspk', //Index for the primary key
      'type' => 'primary',
      'fields' => 
      array (
        0 => 'id',
      ),
    ),
    1 => 
    array (
      'name' => 'campaigns_producttemplates_alt', //Index for the foreign keys
      'type' => 'alternate_key',
      'fields' => 
      array (
        0 => 'campaign_id', //Change this to the left side key
        1 => 'product_template_id', //Change this to the right side key
      ),
    ),
  ),
);

3: 将以下内容放入 custom/extension/modules/campaigns/ProductTemplatesRelate.php

$dictionary['Campaign']['relationships']['producttemplates'] = array(    
'name'         => 'producttemplates',
'type'         => 'link', //Keep as this
'relationship' => 'campaigns_producttemplates', //Many to Many relationship table
'module'       => 'ProductTemplates',
'bean_name'    => 'ProductTemplates',
    'source'       => 'non-db', //Leave as is
    'vname'        => 'LBL_PRODUCTTEMPLATES',
);

4: 将以下内容放入 custom/extension/modules/campaigns/ext/layoutdefs/product_templates_subpanel.php

<?php 
$layout_defs['Campaigns']['subpanel_setup']['producttemplates'] = array(
    'order'             => 100,
    'module'            => 'ProductTemplates', //I believe this is the name of Subpanel Module's directory
    'get_subpanel_data' => 'product_templates', 
    'sort_order'        => 'asc',
    'sort_by'           => 'name',
    'subpanel_name'     => 'default',
    'title_key'         => 'LBL_PRODUCTTEMPLATES',
    'top_buttons'       => array (
        0 => array (
            'widget_class' => 'SubPanelTopSelectButton',
            'mode'         => 'MultiSelect',
        ),
    ),
);

5: 在 custom/modules/ProductTemplates/metadata/subpanels/default.php 中添加以下内容

<?php// created: 2013-11-07 08:42:31
$subpanel_layout['list_fields'] = array (
  'name' => 
  array (
    'type' => 'name',
    'link' => true,
    'vname' => 'LBL_NAME',
    'width' => '10%',
    'default' => true,
    'widget_class' => 'SubPanelDetailViewLink',
    'target_module' => NULL,
    'target_record_key' => NULL,
  ),
);

通过反复试验,我已经走到了这一步,并尝试将其他帖子和帮助文章中的内容拼凑在一起,但无法进一步了解。

我可以确认以下内容:

  • 关系显示在工作室

  • 子面板显示 Studio 中的字段

  • 我的 campaigns_producttemplates 表存在于数据库中

  • 数据库中关系表中存在一行

我能看到的唯一日志条目是:

05/05/15 12:54:30 [1604][1][FATAL] Bad subpanel definition, it has incorrect value for get_subpanel_data property producttemplates

如有任何帮助,我们将不胜感激!

最佳答案

经过大量的搜索和测试,我弄清楚了我的问题所在:

项目 3:

<?php

$dictionary['Campaign']['fields']['campaigns_producttemplates'] = array(
    'name'         => 'campaigns_producttemplates',
    'type'         => 'link', //Keep as this
    'relationship' => 'campaigns_producttemplates', //Many to Many relationship table
    //'module'     => 'ProductTemplates',
    //'bean_name'      => 'ProductTemplate',
    'source'       => 'non-db', //Leave as is
    'vname'        => 'LBL_CAMPAIGN_PRODUCT_TEMPLATES_FROM_CAMPAIGNS_TITLE',
);

这需要是“领域”,而不是“关系”。

和 4:

<?php

$layout_defs['Campaigns']['subpanel_setup']['campaigns_producttemplates'] = array(
    'order'             => 100,
    'module'            => 'ProductTemplates', //I believe this is the name of Subpanel Module's directory
    'get_subpanel_data' => 'campaigns_producttemplates', 
    'sort_order'        => 'asc',
    'sort_by'           => 'id',
    'subpanel_name'     => 'default',
    'title_key'         => 'LBL_PRODUCTTEMPLATES',
    'top_buttons'       => array (
        0 => array (
            'widget_class' => 'SubPanelTopSelectButton',
            'mode'         => 'MultiSelect',
        ),
    ),
);

我需要确保我使用自定义关系来获取子面板的数据。

现在一切正常。

关于sugarcrm - 广告系列和产品模板之间的自定义多对多关系子面板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30052740/

相关文章:

php - 警告 : require_once(modules/Home/metadata/popupdefs. php)

php - 2个表之间的SQL查询

javascript - SuiteCRM 内联编辑字段未保存

python - SugarCRM 过滤器 PYTHON

full-text-search - Sugar CRM CE版全文搜索

php - 命令不同步;您现在无法使用 mysql 存储过程在 SugarCRM 中运行此命令

sugarcrm - 升级到另一个版本

sugarcrm - SugarCRM 中每个文件的第一行的含义是什么

java - SugarCRM 自定义字段

php - 无法在模块构建器中创建包或在 SuiteCRM 中部署新包