在Sugarcrm中的Email模板中添加自定义/关联字段

时间:2012-12-05 12:32:31

标签: sugarcrm

我创建了一个名为调查的自定义模块,它与目标存在多种关系。我需要在向目标发送广告系列邮件时插入调查名称。

目前,我设法通过遵循电子邮件模板中adding a custom module in insert variable dropdownlist的指南来填充插入变量中的调查模块实体,但问题是它永远不会解析调查名称并在已发送的电子邮件中显示$ survey_name。

任何帮助/指导来解决这个问题。

1 个答案:

答案 0 :(得分:0)

我刚刚在该论坛上添加了答案。 sugarCrm EmailTemplate模块基本上是很多代码,只需几个bean工作(帐户,联系人,潜在客户,用户,潜在客户),我得到一些模板与其他bean一起使用这个步骤,这段代码基于SugarCrm 6.0.2,论坛上的class modules / Email.php详细信息:

1)让Email.php创建自己的bean。示例:LOC510

if (... $_REQUEST['parent_type'] == 'Prospects' || TRUE)

2)创建一个替换字段数组。示例:LOC521

  foreach($bean->field_defs as $key => $field_def) {
    $replace_fields ['$'.strtolower(get_class($bean).'_'.$field_def['name'])] 
    = $bean->$field_def['name'];
    //example of fieldnames: $bug_name, $bug_type, $case_date_created, $case_name, etc...
  }

3)替换html模板上的字段。示例:LOC545

$this->description_html = str_replace(array_keys($replace_fields), $replace_fields, $this->description_html);

3)替换txt模板上的字段。示例:LOC549

$this->description = str_replace(array_keys($replace_fields), $replace_fields, $this->description);
相关问题