We’re using Kreporter v3.1. Do you know how can we get an automatic notification email when a user assigns the report to a different one from himself? In other modules we can do this adding the set_notification_body function in the base class and modifying the notify template’s html, but for Kreporter it is not working. Where should we add the set_notification_body function?
Pat,
in KReporter 3.1. save functionality is called over controller.
Please modify function action_save() in modules/KReports/controller.php by passing true in bean->save().
See my screenshot.
This will trigger send notification logic.
I need now to customize the email template that is sent when the report is assigned to another user (different from the one who created it). I have been trying different labels on Sugar’s HTML notify template for several hours unsuccessfully.
Pat,
You will have to add a set_notification_body() function in KReport Class.
Look at modules/Opportunities/Opportunity.php -> set_notification_body() and get inspired.
Thanks for your reply. I already added it, but the email received is the default and I need to send a custom one. I suspect that the problem is in the label I use in the HTML template, which has the following structure:
A report has been assigned to you
{ASSIGNER} has assigned a report to {ASSIGNED_USER}.
You may review this report at:
<{URL}>
I have tried a lot ot labels (KReports, Kreports, KREPORTS, KReport, Kreport, KREPORT, …) but no one has worked.
I just implemented the code in a SugarCRM CE 6.5.18, it works.
Do you have multiple languages and may only 1 notify_template which is not the one for the default language set?
What can also do is
debug include/utils.php get_notify_template_file() to see if the right template is retrieved,
re-check where you inserted code parts.
re-check the name of your custom/include/language/en_us.notify_template.html
The notify_template (custom/include/language/en_us.notify_template.html). It includes the following code for KReporter in the language used in Sugar (english):
<!-- BEGIN: KReport_Subject -->
SpiceCRM KReport - {KREPORT_NAME}
<!-- END: KReport_Subject -->
<!-- BEGIN: KReport -->
{ASSIGNER} has assigned a Report to {ASSIGNED_USER}.
Name: {KREPORT_NAME}
You may review this Report at:
<{URL}>
<!-- END: KReport -->
The controller (modules/KReports/controller.php). It has the true parameter in action_save function:
function action_save() {
global $mod_strings;
if (empty($this->bean->name)) {
$this->bean->name = $mod_strings[‘LBL_DEFAULT_NAME’];
}
$this->bean->save(true);
}
The KReport class (modules/KReports/KReport.php). It includes the set_notification_body function:
function set_notification_body($xtpl, $kreport){
$xtpl->assign(“KREPORT_NAME”, $kreport->name);
return $xtpl;
}
The include/utils.php, debugging it. The right template is retrieved, but instead of taking KReport’s template it takes default’s one:
<!-- BEGIN: Default_Subject -->
[CRM] Assigned {OBJECT}
<!-- END: Default_Subject -->
<!-- BEGIN: Default -->
{ASSIGNER} has assigned a(n) {OBJECT} to {ASSIGNED_USER}.
You may review this {OBJECT} at:
<{URL}>
<!-- END: Default -->
I can’t find what is wrong. My version is Sugar CE 6.5.11 (Build 8754).
In my code the template part is defined for KReport. The comments have a meaning in an xtemplate. They define the blocks that will be parsed. In your template you define for default, not for KReport.
I installed a sugar ce 6.5.11, loaded KReporter 3.1, customized as described. It works.
Any error in sugarcrm.log?
What is your php version? I used 5.6.
Next debug step is function parse() in XTemplate/xtpl.php