例如,在Opportunities和Cases中,有直接指向帐户的关系字段。我有一个自定义模块集成到这些模块。我可以为自定义模块添加一个单独的关联字段,但我想要的是一个灵活的关联,只允许帐户和自定义模块。这可以通过在parent_name中设置一个特殊的选项列表来实现。但是结果是在db中的parent_type和parent_id字段
我如何配置flexrelate,以便在选择帐户作为parent_type时保存到account_id,并选择自定义模块保存到它的id字段?
flexrelate的选项:
$app_list_strings['parent_type_display_custom']['CustomMod'] = 'CustomMod';
$app_list_strings['parent_type_display_custom']['Accounts'] = 'Accounts';
$app_list_strings['record_type_display_custom']['CustomMod'] = 'CustomMod';
$app_list_strings['record_type_display_custom']['Accounts'] = 'Accounts';
case的附加变量:
$dictionary["Case"]["fields"]["parent_type"] = array (
'name' => 'parent_type',
'type' => 'link',
'vname' => 'LBL_PARENT_TYPE',
'type' => 'parent_type',
'dbType' => 'varchar',
'group' => 'parent_name',
'options' => 'parent_type_display_custom',
'len' => '255',
);
$dictionary["Case"]["fields"]['parent_name'] =
array(
'name' => 'parent_name',
'parent_type' => 'record_type_display',
'type_name' => 'parent_type',
'id_name' => 'parent_id',
'vname' => 'LBL_RELATED_TO',
'type' => 'parent(_custom)',
'source' => 'non-db',
'options' => 'record_type_display_custom',
);
$dictionary["Case"]["fields"]['parent_id'] =
array(
'name' => 'parent_id',
'vname' => 'LBL_PARENT_ID',
'type' => 'id',
'required' => false,
'reportable' => true,
'comment' => 'eighter the Id of an account or a custommodule'
);
这篇SugarCRM开发者博客文章有帮助吗?
http://developers.sugarcrm.com/wordpress/2011/05/16/howto-create-a-flex-relate-for-other-modules/