Menu
SuiteCRM Pull Request Party hosted by SalesAgility
Welcome, Guest
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Email Template Insert Variable

Email Template Insert Variable 1 year 3 months ago #60586

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10170
  • Thank you received: 1526
  • Karma: 351
Hi. I am not sure how to answer this since I don't use these functions much. But from your description I would say that it is correctly translating fields in the current module (Contacts) but not in related modules.

You see, the assigned user is kept just as an id in the Contacts table, but then the actual user name needs to be picked up from the Users table.

Now, I am not sure if using related fields in a Templates is supposed to work, or if it never worked. But my guess is that it should be working, but bot broken somehow.

Please have a look on GitHub to see if you can find this Issue already reported; if not, then open an Issue for this. Thanks.

github.com/salesagility/SuiteCRM/issues

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Email Template Insert Variable 6 months 3 weeks ago #74764

  • pstevens
  • pstevens's Avatar
  • Offline
  • Elite Member
  • Posts: 191
  • Thank you received: 21
  • Karma: 4
I know I'm kind of late to the part on this one. Trying to do the same thing. In replying to the other gentleman who asked the question.... If your email is related to "leads" you can only insert fields from the lead module. The rest will not work. If you relate the email to "contacts" you can only add fields form the contact record. This is how it has always worked. (it would be nice if you could relate between modules somehow!)

I also want to insert the "assigned user name" but using the "lead" record for the email only has User ID and User Name (the login name, not the full name).

I guess I could create a field in the lead to populate via workflow with the assigned user's full name, then it would be available to pick from for the letter, but that seems like a long way around. Anyone have any simpler ideas?
The administrator has disabled public write access.

Email Template Insert Variable 6 months 2 weeks ago #74783

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10170
  • Thank you received: 1526
  • Karma: 351
@pstevens I've also used the workaround you suggest in the past. It might seem overly complicated but it works and is automatic, so people quickly forget it is an issue.

I admit it would be quite nice to be able to use related fields in email templates.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 weeks ago #77158

  • halooooom
  • halooooom's Avatar
  • Offline
  • New Member
  • Posts: 13
  • Karma: 0
When the email arrives in the test account it shows:



Dear $lead_first_name $lead_webtolead_email1 $lead_email1 $lead_name $lead_assigned_user_id $lead_last_name


- I.e. non of the variables from the leads module are populating with the lead information?

Was this resolved?
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 weeks ago #77161

  • amart817
  • amart817's Avatar
  • Offline
  • New Member
  • Posts: 17
  • Karma: 1
I gave up and wrote my own parser and a bunch of replacement tokens. It was not an upgrade safe change.
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 weeks ago #77170

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10170
  • Thank you received: 1526
  • Karma: 351
Can you please try this on 7.11?

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 weeks ago #77172

  • amariussi
  • amariussi's Avatar
  • Offline
  • SuiteCRM Is My Life
  • Posts: 1295
  • Thank you received: 284
  • Karma: 65
@amart817
I gave up and wrote my own parser and a bunch of replacement tokens. It was not an upgrade safe change.

Since, even with this problem, you are still using SuiteCRM, could you share here a full description of your code, including sources, so that all can benefit of your improvements?

Thanks!

You may also add these in gitHub so that your code is no longer upgrade unsafe!
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 weeks ago #77185

  • halooooom
  • halooooom's Avatar
  • Offline
  • New Member
  • Posts: 13
  • Karma: 0
Upgraded to 7.11, emails now won't send at all just got a spinning wheel so can't tell if the prior issue was fixed
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 weeks ago #77189

  • amart817
  • amart817's Avatar
  • Offline
  • New Member
  • Posts: 17
  • Karma: 1
I have done a lot of unsafe changes. We were in a bit of a hurry to get the things we needed added to the CRM. A lot of those changes revolved around the Email module, especially Inbound Emails. The company is trying to decide if it is best to fork from here or attempt to stay up to date with SuiteCRM. At the moment, there is too much work to be done for to focus on that.
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 weeks ago #77191

  • amart817
  • amart817's Avatar
  • Offline
  • New Member
  • Posts: 17
  • Karma: 1
Here is what I did for the tokens...

File: modules/Emails/Email.php
line 570ish (depending how many lines above I have added or subtracted)

You will find, this is where the parser happens:
$this->description_html = EmailTemplate::parse_template($this->description_html, $object_arr);
$this->name = EmailTemplate::parse_template($this->name, $object_arr);
$this->description = EmailTemplate::parse_template($this->description, $object_arr);

That wasn't doing good enough for me. So I added the following below it:
require_once('custom/include/TemplateTokens.php');
$this->description_html = TemplateTokens::replace($this->description_html, $object_arr);
$this->name = TemplateTokens::replace($this->name, $object_arr);
$this->description = TemplateTokens::replace($this->description, $object_arr);

TemplateTokens is a custom class I wrote.

$object_arr already holds the related beans.

My TemplateTokens::replace method simply looks for any tokens, example: {leads_first_name}

Then it splits it at the first underscore.

So it knows it needs to get the 'first_name' property from the 'leads' bean that is in the $object_arr.

Then I have a few custom tokens like, {today_date} which replaces it with a formatted date.

I also have one that is {leads_user_fullname} which knows it needs to get the full name of the person that is assigned to the lead.

There are few others that are specific to our needs,
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 weeks ago #77215

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10170
  • Thank you received: 1526
  • Karma: 351
Version 7.11.1 is out.

I ask that you please try it and see how it goes.

If this issue here isn't solved in 7.11.1, I need to make sure it gets fixed in the next one. The focus of the past weeks has been on email issues, and there will be at least one more sprint focused on that, so let's make sure we get this to a satisfactory state.

So please help us test and give me your feedback, I'll be waiting for it to determine the next steps. Thanks!

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 weeks ago #77237

  • amart817
  • amart817's Avatar
  • Offline
  • New Member
  • Posts: 17
  • Karma: 1
What I did was a bit of a hack and wouldn't suggest anyone else doing it. I'm sure there is a more graceful solution. I would rather wait until I have the time to do it right before sharing. As for updating to 7.11, we are currently stuck on 7.8.8 because of all the breaking changes we made.
The administrator has disabled public write access.

Email Template Insert Variable 4 months 3 days ago #77767

  • stephenmchugh
  • stephenmchugh's Avatar
  • Offline
  • Senior Member
  • Posts: 56
  • Thank you received: 6
  • Karma: 0
Is my error related to this? After upgrading to 7.11.1 fro 7.10.7 I cannot get email variable to populate in a campaign email.

Log file:
Wed Feb 13 16:44:04 2019 [13344][1][ERROR] Pop error level. Try to remove the error_reporting() function from your code.
Wed Feb 13 16:44:05 2019 [13344][1][ERROR] Unable to find relationship emails_email_templates
Wed Feb 13 16:44:05 2019 [13344][1][ERROR] Saving Email with invalid From name and/or Address. Details:
From field is not set.
From-name is not set.
From name is not set.
codes:1, 7, 10
Wed Feb 13 16:44:05 2019 [13344][1][ERROR] Unable to find relationship emails_email_templates
Wed Feb 13 16:44:06 2019 [13344][1][ERROR] Pop error level. Try to remove the error_reporting() function from your code.

(note: there are multiple "Pop error level" entries before and after)

The Campaign email template is new and simple and it looks OK. It has the From name set. Any clues? Suggestions?

TIA
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 days ago #77801

  • stephenmchugh
  • stephenmchugh's Avatar
  • Offline
  • Senior Member
  • Posts: 56
  • Thank you received: 6
  • Karma: 0
@PGR, I have a selfish interest in getting the Campaign email module working so let me know if you me to help with any testing of campaign emails on 7.11.1
The administrator has disabled public write access.

Email Template Insert Variable 4 months 2 days ago #77809

  • pgr
  • pgr's Avatar
  • Offline
  • Administrator
  • Posts: 10170
  • Thank you received: 1526
  • Karma: 351
You can help in the following way:

- search GitHub to see if the issue is already there

- if not, make sure you open a new issue

- make the issue template complete and accurate, that helps.

My SuiteCRM In-depth blog.
Thank you for always stating your SuiteCRM version, checking your logs, reading the Docs, and searching before you ask!
The administrator has disabled public write access.
  • Page:
  • 1
  • 2
Time to create page: 0.044 seconds
Powered by Kunena Forum