Extended modules Email Template variables #5167

Open
opened 2026-02-20 16:30:49 -05:00 by deekerman · 2 comments
Owner

Originally created by @ojs87 on GitHub (Feb 6, 2024).

Issue

Modules that are extended in the custom folder, e.g. AOS_Quotes.php, are not correctly replacing variables based on the variables available in the Email Templates module. This is due to an extended module using a different beanList name(e.g. customAOS_Quotes) and the template parser using that beanList name as the key for the variables.

Expected Behavior

Extended modules should still be able to use the basic variable options in the email template editor

Actual Behavior

The basic variables aren't parsed.

Possible Fix

use the $bean->table_name as a key for template_parser, rather than the name of the module in the $beanList global array.

Steps to Reproduce

  1. Extend the AOS_Quotes.php file by adding it to the custom/modules/AOS_Quotes folder and creating a basic class
<?php
if (!defined('sugarEntry') || !sugarEntry) {
    die('Not A Valid Entry Point');
}
require_once('modules/AOS_Quotes/AOS_Quotes_sugar.php');

class CustomAOS_Quotes extends AOS_Quotes_sugar
{
    public function save($check_notify = false)
    {
    
        $saved = parent::save($check_notify);

          return $saved;
       }
}
  1. Add the required global name changes for the module in custom/Extension/application/Ext/Include/AOS_Quotes.php file
<?php
$objectList['AOS_Quotes'] = 'AOS_Quotes';
$beanList['AOS_Quotes'] = 'CustomAOS_Quotes';
$beanFiles['CustomAOS_Quotes'] = 'custom/modules/AOS_Quotes/CustomAOS_Quotes.php';
  1. Repair and rebuild and create an email template for quotes, then a workflow to send an email when a quote is created
  2. Create a quote
  3. The sent email will not parse the variables correctly

Your Environment

  • SuiteCRM Version used: 7.14.3
  • Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)):
  • Environment name and version (e.g. MySQL, PHP 7): PHP 7.4
  • Operating System and version (e.g Ubuntu 16.04): Ubuntu 22.04.3 LTS
Originally created by @ojs87 on GitHub (Feb 6, 2024). <!--- Provide a general summary of the issue in the **Title** above --> <!--- Before you open an issue, please check if a similar issue already exists or has been closed before. ---> <!--- If you have discovered a security risk please report it by emailing security@suitecrm.com. This will be delivered to the product team who handle security issues. Please don't disclose security bugs publicly until they have been handled by the security team. ---> <!--- Please be aware that as of the 31st January 2022 we no longer support 7.10.x. New issues referring to 7.10.x will only be valid if applicable to 7.12.x and above. If your issue is still applicable in 7.12.x, please create the issue following the template below --> #### Issue Modules that are extended in the custom folder, e.g. AOS_Quotes.php, are not correctly replacing variables based on the variables available in the Email Templates module. This is due to an extended module using a different beanList name(e.g. customAOS_Quotes) and the template parser using that beanList name as the key for the variables. #### Expected Behavior Extended modules should still be able to use the basic variable options in the email template editor #### Actual Behavior The basic variables aren't parsed. #### Possible Fix use the $bean->table_name as a key for template_parser, rather than the name of the module in the $beanList global array. #### Steps to Reproduce <!--- Provide a link to a live example, or an unambiguous set of steps to --> <!--- reproduce this bug include code to reproduce, if relevant --> 1. Extend the AOS_Quotes.php file by adding it to the custom/modules/AOS_Quotes folder and creating a basic class ``` <?php if (!defined('sugarEntry') || !sugarEntry) { die('Not A Valid Entry Point'); } require_once('modules/AOS_Quotes/AOS_Quotes_sugar.php'); class CustomAOS_Quotes extends AOS_Quotes_sugar { public function save($check_notify = false) { $saved = parent::save($check_notify); return $saved; } } ``` 2. Add the required global name changes for the module in custom/Extension/application/Ext/Include/AOS_Quotes.php file ``` <?php $objectList['AOS_Quotes'] = 'AOS_Quotes'; $beanList['AOS_Quotes'] = 'CustomAOS_Quotes'; $beanFiles['CustomAOS_Quotes'] = 'custom/modules/AOS_Quotes/CustomAOS_Quotes.php'; ``` 3. Repair and rebuild and create an email template for quotes, then a workflow to send an email when a quote is created 4. Create a quote 5. The sent email will not parse the variables correctly #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.14.3 * Browser name and version (e.g. Chrome Version 51.0.2704.63 (64-bit)): * Environment name and version (e.g. MySQL, PHP 7): PHP 7.4 * Operating System and version (e.g Ubuntu 16.04): Ubuntu 22.04.3 LTS
Author
Owner

@johnM2401 commented on GitHub (Feb 12, 2024):

Hey @ojs87 !

Apologies if I'm wrong, but this looks like it might be a duplicate of: https://github.com/salesagility/SuiteCRM/issues/10307

Which is resolved by: https://github.com/salesagility/SuiteCRM/pull/10308
(Which was pulled into the latest release)

Is that right?

If not, I'm happy to investigate this ticket further
Thanks!

@johnM2401 commented on GitHub (Feb 12, 2024): Hey @ojs87 ! Apologies if I'm wrong, but this looks like it might be a duplicate of: https://github.com/salesagility/SuiteCRM/issues/10307 Which is resolved by: https://github.com/salesagility/SuiteCRM/pull/10308 (Which was pulled into the latest release) Is that right? If not, I'm happy to investigate this ticket further Thanks!
Author
Owner

@ojs87 commented on GitHub (Feb 12, 2024):

hey @johnM2401,

This looks like the same issue with using the beanList on an extended module but #10308 deals with building the smarty templates and this fix deals with parsing email templates so I don't think #10308 fixes this issue. Maybe the team would prefer to fix my issue in a similar way though.

Good catch though I didn't see that other PR when searching for dupes.

Cheers!

@ojs87 commented on GitHub (Feb 12, 2024): hey @johnM2401, This looks like the same issue with using the beanList on an extended module but #10308 deals with building the smarty templates and this fix deals with parsing email templates so I don't think #10308 fixes this issue. Maybe the team would prefer to fix my issue in a similar way though. Good catch though I didn't see that other PR when searching for dupes. Cheers!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/SuiteCRM-SuiteCRM#5167
No description provided.