salesagility / SuiteCRM

SuiteCRM - Open source CRM for the world
https://www.suitecrm.com
GNU Affero General Public License v3.0
4.44k stars 2.07k forks source link

Extended modules Email Template variables #10355

Open ojs87 opened 8 months ago

ojs87 commented 8 months ago

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;
   }

}

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
johnM2401 commented 7 months ago

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!

ojs87 commented 7 months ago

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!