mirror of
https://github.com/SuiteCRM/SuiteCRM.git
synced 2026-03-02 19:16:58 -05:00
Email Template Not Replacing Contact/Lead/Target Name Variable in Leads #3423
Labels
No labels
Area: API
Area: Campaigns
Area: Cases
Area: Clean Up
Area: Clean Up: Performance
Area: Dashlets
Area: Databases
Area: Developer Tools
Area: Elasticsearch
Area: Elasticsearch
Area: Emails
Area: Emails:Campaigns
Area: Emails:Cases
Area: Emails:Compose
Area: Emails:Config
Area: Emails:Templates
Area: Environment
Area: Installation
Area: Language
Area: Mobile
Area: Module
Area: PDFs
Area: PHP8
Area: Reports
Area: Studio
Area: Styling
Area: Upgrading
Area: Workflow
Area:Activity Stream
Area:Calls
Area:Import
Area:Projects
Area:Search
Area:Surveys
Area:Themes
Area:Users
Branch:Hotfix
Good First Issue
Hacktoberfest
Help Wanted
PR:Community Contribution
PR:Type:Enhancement
Priority:Critical
Priority:Important
Priority:Moderate
Severity: Major
Severity: Minor
Severity: Moderate
Status: Requires Code Review
Status: Requires Updates
Status: Stale
Status: Team Investigating
Status:Assessed
Status:Fix Proposed
Status:Needs Assessed
Status:Requires Automated Tests
Type: Bug
Type:Deprecated
Type:Discussion
Type:Duplicate
Type:Invalid
Type:Question
Type:Suggestion
Type:Suggestion
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SuiteCRM-SuiteCRM#3423
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pstevens71 on GitHub (Nov 27, 2018).
Originally assigned to: @Dillon-Brown, @cameronblaikie, @jack7anderson7 on GitHub.
Issue
I do see there are other issues with emails already listed #3829 #3321 #3310 #6462 but don't seem to be exactly the same but may be related.
When creating an email template and then inserting Contact/Lead/Target variable for $contact_first_name, for example if you send it to a lead it does not work (it worked in previous versions) it just leaves the variable there. However, this works fine if you send it to a contact and replaces the variable with the first name no problem. If I use the variable $lead_first_name and send it to a lead it work no problem. However, using the Contact/Lead/Target variable is supposed to grab the right first name regardless of the record.
I should mention, it works as part of a workflow and subs in the right variable, just when you select a single lead to send an email to, it doesn't populate the value.
Expected Behavior
Using the Contact/Lead/Target variable is supposed to grab the right first name regardless of the record when used in a template
Actual Behavior
When creating an email template and then inserting Contact/Lead/Target variable for $contact_first_name, for example if you send it to a lead it does not work (it worked in previous versions) it just leaves the variable there as $contact_first_name when sending to the client.
I've checked error.log and there are no errors there to report.
Possible Fix
Steps to Reproduce
Context
This should be a high priority. Sending out emails to people that you can't personalize kind of defeats the purpose of a CRM! Looks like there are lots of bugs around sending emails and variables. Would be great to get this fixed.
Your Environment
@cameronblaikie commented on GitHub (Dec 12, 2018):
I have tested this and the variable only displays properly on the Detail View but does not display on the list view.
@samus-aran commented on GitHub (Dec 13, 2018):
As @cameronblaikie Stated that this is still an issue on the List View of these modules so will create a ticket specifically to this issue and refer to this issue. @jack7anderson7 Can you do that for me if you haven't done so already.
@jack7anderson7 commented on GitHub (Dec 13, 2018):
This is the link to the other Issue
#6611
@apexred commented on GitHub (Feb 28, 2019):
I see this is closed but my campaigns AND emails still have the same problem as described by @pstevens71: "When creating an email template and then inserting Contact/Lead/Target variable for $contact_first_name, for example if you send it to a lead it does not work (it worked in previous versions) it just leaves the variable there as $contact_first_name when sending to the client."
This error in this log MAY or MAY NOT be related. The email is successfully sent but the email variable doesn't work.
I set the log to debug and this is where it seems to go fubar..... (but there are many other entries):
Thu Feb 21 15:24:55 2019 [12015][1][ERROR] Saving Email with invalid From name and/or Address. Details:
From field is not set.
From-name is not set.
From address and name pair is empty.
codes:1, 7, 14
Thu Feb 21 15:24:55 2019 [12015][1][ERROR] Unable to find relationship emails_email_templates
Thu Feb 21 15:24:55 2019 [12015][1][ERROR] Unable to find relationship emails_email_templates
Thu Feb 21 15:24:55 2019 [12015][1][ERROR] Unable to find relationship emails_email_templates
Thu Feb 21 15:24:55 2019 [12015][1][ERROR] Invalid email from address or name detected before sending. Details:
From field is not set.
From-name is not set.
From address and name pair is empty.
codes:1, 7, 14
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Saving Email with invalid From name and/or Address. Details:
From field is not set.
From address is not set.
From-name is not set.
From name is not set.
From address and name pair is empty.
codes:1, 4, 7, 10, 14
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Unable to find relationship emails_email_templates
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Saving Email with invalid From name and/or Address. Details:
From field is not set.
From address is not set.
From-name is not set.
From name is not set.
From address and name pair is empty.
codes:1, 4, 7, 10, 14
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Unable to find relationship emails_email_templates
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] fromUser: Conversion of from user format Y-m-d H:i failed
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Saving Email with invalid From name and/or Address. Details:
From field is not set.
From-name is not set.
From address and name pair is empty.
codes:1, 7, 14
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Unable to find relationship emails_email_templates
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Unable to find relationship emails_email_templates
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Unable to find relationship emails_email_templates
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Array
(
[0] => Unhandled email save and store as sent error: 1
[1] => 6
)
Thu Feb 21 15:24:57 2019 [12015][1][ERROR] Array
(
[0] => Unhandled non gmail sent folder hander error: 2
[1] => 100
)
@apexred commented on GitHub (Mar 4, 2019):
@pgorod (assuming you are 'pgr' on the forums?) how should I get this issue reopened? Or do I create a new issue?
@pgorod commented on GitHub (Mar 6, 2019):
Yes I am him 🕵️
Your best option to get stuff reopoened is to try and get @Dillon-Brown to take another look at this...
@Dillon-Brown commented on GitHub (Mar 6, 2019):
👀
@apexred commented on GitHub (Mar 6, 2019):
Yay Dillon!
Tell me what you need and I will attempt to help you in any way I can.
Steve
@apexred commented on GitHub (Mar 12, 2019):
FYI, there's another topic created on the Forum, detailing the same problem:
https://suitecrm.com/suitecrm/forum/suitecrm-7-0-discussion/22028-campaign-variables-in-email-template-are-blank-in-email-received-7-11-1-7-11-2#78739
@IFTSgit commented on GitHub (Mar 30, 2019):
Just upgraded from 7.10.9 to 7.11.3. Issue persists, but I didn't see this issue number in the release notes, so that makes sense. I'm also having a problem with no variables working from campaigns (simply shows up as blanks in emails being sent) and when composing an email from a template (variable name shows up in emails being sent rather than blank). Is this part of the same bug/issue, or are they separate and I've just missed one of them in the issue list?
@apexred commented on GitHub (Apr 10, 2019):
Additional observation that might help the devs here: Email variables DO work with CONTACTS on 7.11.3 but LEADS and TARGETS don't work.
Any resolution in sight?
@sru001 commented on GitHub (Apr 17, 2019):
I can confirm the issue with my installation:
php 7.2
suitecrm 7.11.3
Variables are parsed only for the specific module it refers to e.g.
This is similar for variables: $contact_salutation $contact_last_name
Hope this might hint in the right direction, @Dillon-Brown ?
@adminibt commented on GitHub (Jul 4, 2019):
Same problem in 7.10.18.
Look at modules/EmailTemplates/EmailTemplateParser.php (arround line number 180):
...
$parts = explode($charUnderscore, ltrim($variable, $charVariable));
list($moduleName, $attribute) = [array_shift($parts), join($charUnderscore, $parts)];
if (in_array($attribute, static::$allowedVariables, true)) {
return $this->getNonDBVariableValue($attribute);
}
// if ($this->module instanceof $moduleName && property_exists($this->module, $attribute)) {
if (property_exists($this->module, $attribute)) {
if (isset($this->module->field_name_map[$attribute]['type']) && ($this->module->field_name_map[$attribute]['type']) === 'enum') {
$enum = $this->module->field_name_map[$attribute]['options'];
...
The problem is in the line which is commented out; the following line has been added.
This is just a workarround. Works for me with campaign mails.
Might be similar in 7.11.x.
@connorshea commented on GitHub (Aug 1, 2019):
@samus-aran should the milestone be removed from this issue?
@pgorod commented on GitHub (Aug 2, 2019):
Maybe it should be added to the next milestone? :-)
@Dillon-Brown commented on GitHub (Aug 2, 2019):
Will add it to the sprint for now. I'll be taking a look at automating some of these processes this sprint, will need to also think about what the best way to track is with multiple branches.
@dtosun61 commented on GitHub (Aug 2, 2019):
So what is fix?
@lazka commented on GitHub (Sep 16, 2019):
This was introduced with #5337 (by just skipping the template parser) which was reverted in #5397 and then re-added in #5425 with a ""refactoring""
@lazka commented on GitHub (Sep 16, 2019):
I've created #7866 with a minimal fix. An alternative would be to revert the parts of #5425 that are not a refactoring.
@EvilWatermelon commented on GitHub (Sep 17, 2019):
Did you guys already found a solution for these errors with the variables in suite?
@apexred commented on GitHub (Sep 17, 2019):
We use a fudge fix. An example email:
Hi $prospect_first_name$lead_first_name$contact_first_name,
...
Not pretty, but it works.
@EvilWatermelon commented on GitHub (Sep 19, 2019):
Okey, thanks.
I tried it and it works for 50%.
If I write a new Email and change a account, contact, etc. from the "Related To:"-field than it works for this specific field.
For example:
I want to fill the variables for contacts but my template have variables for contacts and accounts - then my contact variables will be changed but not my account variables.
You understand what I want to say?
Is there a way to fill all different variables?
@apexred commented on GitHub (Sep 19, 2019):
Not sure I understand completely. Can you show a list of all your variables here?
@pstevens71 commented on GitHub (Sep 19, 2019):
I think I know what he's talking about. I've never been able to use cross module variables in emails as a variable. So for example if I want to send a letter to $contact_first_name and then finish it with Sincerely, $user it just won't work. Relate fields have never worked to get populated for me. Any other variable in the lead module (if sending to a lead) works.
@pgorod commented on GitHub (Sep 20, 2019):
What @pstevens71 says is true, from my (indirect) experience of seeing people in the Forums stumbling on this. I wonder if we simply don't have code to pull in variables from related modules, or if we have it, but some bug has crept in and broken it... 🤔
@pstevens71 commented on GitHub (Sep 20, 2019):
As a quick workaround for anyone who needs to get a cross module relate field into an email template, I usually just create a text field in the LEAD and then set up an on save workflow to populate it with relate field value. This works.
@timo-ecm2 commented on GitHub (Nov 18, 2019):
Great that this issue is almost resolved,
I checked your solution and it works for us only when I work with the Campaign module.
When I send a Campaign e-mail with template I see that all the contact/lead/target variables are properly populated.
Only it doesn't work for me when I manually e-mail a lead with that same Campaign e-mail template.
Real result
Dear prospect $prospect_first_name,
Dear lead Timothy;
Dear contact $contact_first_name,
Wanted result
Dear prospect $prospect_first_name,
Dear lead Timothy;
Dear contact Timothy;
System in use
@pgorod commented on GitHub (Nov 26, 2019):
@timo-ecm2 I'm not sure I understand your case. If you are starting the email form within a Lead, then the only variables that would be available to you would be
Leadvariables. It would have no way of knowing whichContactyou mean.@timo-ecm2 commented on GitHub (Nov 26, 2019):
Hi @pgorod, I thought that it was also possible with manual e-mails to use the $contact_first_name, because this Contact/Lead/Target variable is supposed to grab the right first name regardless of the record type (Contact/Lead/Target ).
@ebogaard commented on GitHub (Nov 26, 2019):
Yes, it always used to be that there was one 'special' variable, which is described as "Contact/Lead/Target" (see screenshot in suitecrm documentation below "Email Variables") in the Campaigns-module. This 'special' variable is in the following format: "contact_<field_name>", and would check if it was sent to a Contact, Lead or Target and would fill in the correct variable.
I'm not sure this special variable used to work when sending a single e-mail. It would make creating and maintaining e-mail Templates easier, though!
@pgorod commented on GitHub (Nov 26, 2019):
I've been thinking about this and I opened a new Issue with my suggestion.
#8315
Please follow the discussion there. Thanks!
@rmaclean commented on GitHub (Mar 12, 2025):
Still having this with 8.8 :/