WOF action sendEmail does not replace float custom variables with values (parse_template_bean function) #5085

Open
opened 2026-02-20 16:29:21 -05:00 by deekerman · 3 comments
Owner

Originally created by @gody01 on GitHub (Sep 11, 2023).

Issue

If You have custom field of type float in Emails sent from Workflow there is no substitution for value in EmailTemplate.

Expected Behavior

If You have macro for custom variable (of type float) in sent Email value should be displayed. (It works for string, url type but not for float).

Actual Behavior

Place for the variable is empty.

Possible Fix

In file: modules/AOS_PDF_Templates/templateParser.php there is code to make variables of type 'int' work but not for type 'float'.

Following patch fixes this for us, but I suspect that for type decimal could also be issue...

--- modules/AOS_PDF_Templates/templateParser.php.orig	2023-09-11 21:43:09.803361715 +0200
+++ modules/AOS_PDF_Templates/templateParser.php	2023-09-11 22:17:51.198423337 +0200
@@ -90,7 +90,7 @@
 
                     $repl_arr[$key . "_" . $fieldName] = implode(", ", $translatedVals);
                 } //Fix for Windows Server as it needed to be converted to a string.
-                elseif ($field_def['type'] == 'int') {
+                elseif (($field_def['type'] == 'int') || ($field_def['type'] == 'float')) {
                     $repl_arr[$key . "_" . $fieldName] = (string)$focus->$fieldName;
                 } elseif ($field_def['type'] == 'bool') {
                     if ($focus->{$fieldName} == "1") {

BTW,
just wondering why /srv/www/vhosts/sugar.agenda.si/modules/AOW_Actions/actions/templateParser.php extends template_parser from AOS_PDF_Templates and not use EmailTemplate Bean ?

Steps to Reproduce

  1. In studio, create field test_float_field in module Opportunity (for example)
  2. Create Workflow, which sends Email on Opportunity save
  3. Define template, with defined variable $test_float_field in body
  4. Create new record in Opportunity and see sent Emails (variable won't be substituted).

Context

While automating Opportunity workflows vital data is not sent to appropriate responsible people.

I think this should be high priority as Workflow are only partialy usable and vital data may be missing in important emails.

Your Environment

  • SuiteCRM Version used: 7.11.8, 7.13.4
  • Browser name and version Chrome, Firefox, ...
  • Environment name and version (e.g. MySQL, PHP 7): PHP 7.2, PHP 7.4
  • Operating System and version (e.g Ubuntu 16.04): RockyLinux 7, 8, 9
Originally created by @gody01 on GitHub (Sep 11, 2023). <!--- 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 <!--- Provide a more detailed introduction to the issue itself, and why you consider it to be a bug --> If You have custom field of type float in Emails sent from Workflow there is no substitution for value in EmailTemplate. <!--- Ensure that all code ``` is surrounded ``` by triple back quotes. This can also be done over multiple lines --> #### Expected Behavior <!--- Tell us what should happen --> If You have macro for custom variable (of type float) in sent Email value should be displayed. (It works for string, url type but not for float). #### Actual Behavior <!--- Tell us what happens instead --> Place for the variable is empty. <!--- Also please check relevant logs (suitecrm.log, php error.log etc.) --> #### Possible Fix <!--- Not obligatory, but suggest a fix or reason for the bug --> In file: modules/AOS_PDF_Templates/templateParser.php there is code to make variables of type 'int' work but not for type 'float'. Following patch fixes this for us, but I suspect that for type decimal could also be issue... ``` --- modules/AOS_PDF_Templates/templateParser.php.orig 2023-09-11 21:43:09.803361715 +0200 +++ modules/AOS_PDF_Templates/templateParser.php 2023-09-11 22:17:51.198423337 +0200 @@ -90,7 +90,7 @@ $repl_arr[$key . "_" . $fieldName] = implode(", ", $translatedVals); } //Fix for Windows Server as it needed to be converted to a string. - elseif ($field_def['type'] == 'int') { + elseif (($field_def['type'] == 'int') || ($field_def['type'] == 'float')) { $repl_arr[$key . "_" . $fieldName] = (string)$focus->$fieldName; } elseif ($field_def['type'] == 'bool') { if ($focus->{$fieldName} == "1") { ``` BTW, just wondering why /srv/www/vhosts/sugar.agenda.si/modules/AOW_Actions/actions/templateParser.php extends template_parser from AOS_PDF_Templates and not use EmailTemplate Bean ? #### 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. In studio, create field test_float_field in module Opportunity (for example) 2. Create Workflow, which sends Email on Opportunity save 3. Define template, with defined variable $test_float_field in body 4. Create new record in Opportunity and see sent Emails (variable won't be substituted). #### Context <!--- How has this bug affected you? What were you trying to accomplish? --> While automating Opportunity workflows vital data is not sent to appropriate responsible people. <!--- If you feel this should be a low/medium/high priority then please state so --> I think this should be high priority as Workflow are only partialy usable and vital data may be missing in important emails. #### Your Environment <!--- Include as many relevant details about the environment you experienced the bug in --> * SuiteCRM Version used: 7.11.8, 7.13.4 * Browser name and version Chrome, Firefox, ... * Environment name and version (e.g. MySQL, PHP 7): PHP 7.2, PHP 7.4 * Operating System and version (e.g Ubuntu 16.04): RockyLinux 7, 8, 9
Author
Owner

@gody01 commented on GitHub (Sep 11, 2023):

This refined patch adds support also for decimal type and use Formating of decimal number_separators:

--- templateParser.php.orig     2023-09-11 21:43:09.803361715 +0200
+++ templateParser.php  2023-09-11 23:29:34.301529681 +0200
@@ -92,6 +92,9 @@
                 } //Fix for Windows Server as it needed to be converted to a string.
                 elseif ($field_def['type'] == 'int') {
                     $repl_arr[$key . "_" . $fieldName] = (string)$focus->$fieldName;
+                } elseif (($field_def['type'] == 'float') || ($field_def['type'] == 'decimal')) {
+                    $sep = get_number_separators();
+                    $repl_arr[$key . "_" . $fieldName] = rtrim(rtrim(format_number($focus->$fieldName), $field_def['precision']), $sep[1]);
                 } elseif ($field_def['type'] == 'bool') {
                     if ($focus->{$fieldName} == "1") {
                         $repl_arr[$key . "_" . $fieldName] = "true";
@gody01 commented on GitHub (Sep 11, 2023): This refined patch adds support also for decimal type and use Formating of decimal number_separators: ``` --- templateParser.php.orig 2023-09-11 21:43:09.803361715 +0200 +++ templateParser.php 2023-09-11 23:29:34.301529681 +0200 @@ -92,6 +92,9 @@ } //Fix for Windows Server as it needed to be converted to a string. elseif ($field_def['type'] == 'int') { $repl_arr[$key . "_" . $fieldName] = (string)$focus->$fieldName; + } elseif (($field_def['type'] == 'float') || ($field_def['type'] == 'decimal')) { + $sep = get_number_separators(); + $repl_arr[$key . "_" . $fieldName] = rtrim(rtrim(format_number($focus->$fieldName), $field_def['precision']), $sep[1]); } elseif ($field_def['type'] == 'bool') { if ($focus->{$fieldName} == "1") { $repl_arr[$key . "_" . $fieldName] = "true"; ```
Author
Owner

@serhiisamko091184 commented on GitHub (Mar 4, 2024):

Hello @gody01,

thanks for raising the issue,

I'd like to check with you about my replication steps, as haven't got the result yet. I'm using SuiteCRM version 7.14.3.

  1. I've created a custom field of Float type.

image

  1. I've created Email template with the float field added:

image

  1. I've set the workflow:
    image

  2. Now I create an Opportunity record:

image

image

  1. I've just received an email, based on the template I used for the workflow:

image

The field is present.

Would you be so kind:

  1. to check am I missing something? 'If You have macro for custom variable' - I'm not sure I'm following.

  2. to share what values you have set for the users:
    "Currency Significant Digits"
    "1000s Seperator"
    "Decimal Symbol"

Thanks in advance for your reply!

Regards,
Serhii

@serhiisamko091184 commented on GitHub (Mar 4, 2024): Hello @gody01, thanks for raising the issue, I'd like to check with you about my replication steps, as haven't got the result yet. I'm using SuiteCRM version 7.14.3. 1) I've created a custom field of Float type. ![image](https://github.com/salesagility/SuiteCRM/assets/116086008/6659612f-b6d4-4f4f-bd54-e796ca6fc8ca) 2) I've created Email template with the float field added: ![image](https://github.com/salesagility/SuiteCRM/assets/116086008/4fe906c1-4079-48ae-9cdf-52cde8b60932) 3) I've set the workflow: ![image](https://github.com/salesagility/SuiteCRM/assets/116086008/c6e674fd-7daa-4176-86f4-948d8f398719) 4) Now I create an Opportunity record: ![image](https://github.com/salesagility/SuiteCRM/assets/116086008/ca51537d-9f09-40f1-bddd-18c671fc8554) ![image](https://github.com/salesagility/SuiteCRM/assets/116086008/56a5bebb-bf29-465a-8e4c-716883369f8d) 5) I've just received an email, based on the template I used for the workflow: ![image](https://github.com/salesagility/SuiteCRM/assets/116086008/2e40b467-b34e-4009-83e8-044e913515a9) The field is present. Would you be so kind: 1) to check am I missing something? 'If You have macro for custom variable' - I'm not sure I'm following. 2) to share what values you have set for the users: "Currency Significant Digits" "1000s Seperator" "Decimal Symbol" Thanks in advance for your reply! Regards, Serhii
Author
Owner

@serhiisamko091184 commented on GitHub (Oct 7, 2024):

Hello @gody01,

The issue has been marked as stale because there has been no recent activity. It will be closed if no further activity occurs.
Thanks for your contributions.

Regards,
Serhii

@serhiisamko091184 commented on GitHub (Oct 7, 2024): Hello @gody01, The issue has been marked as stale because there has been no recent activity. It will be closed if no further activity occurs. Thanks for your contributions. Regards, Serhii
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#5085
No description provided.