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.
Using the Contact/Lead/Target variable is supposed to grab the right first name regardless of the record when used in a template
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.
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.
I have tested this and the variable only displays properly on the Detail View but does not display on the list view.
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.
This is the link to the other Issue
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
)
@pgorod (assuming you are 'pgr' on the forums?) how should I get this issue reopened? Or do I create a new issue?
Yes I am him 🕵️
Your best option to get stuff reopoened is to try and get @Dillon-Brown to take another look at this...
:eyes:
Yay Dillon!
Tell me what you need and I will attempt to help you in any way I can.
Steve
FYI, there's another topic created on the Forum, detailing the same problem:
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?
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?
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 ?
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.
@samus-aran should the milestone be removed from this issue?
Maybe it should be added to the next milestone? :-)
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.
So what is fix?
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""
I've created #7866 with a minimal fix. An alternative would be to revert the parts of #5425 that are not a refactoring.
Did you guys already found a solution for these errors with the variables in suite?
We use a fudge fix. An example email:
Hi $prospect_first_name$lead_first_name$contact_first_name,
...
Not pretty, but it works.
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?
Not sure I understand completely. Can you show a list of all your variables here?
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.
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... 🤔
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.
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
@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 Lead variables. It would have no way of knowing which Contact you mean.
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 ).
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_
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!
I've been thinking about this and I opened a new Issue with my suggestion.
Please follow the discussion there. Thanks!