9 votes
Accepted

Extract all occurences of a substring from a string

This is a simple "regular expression" situation. You can use the following code as a starting point: Pattern p = Pattern.compile('\\{!.+?\\}'); string templateContent = 'hello adrian , this is for {!...
user avatar
  • 434k
6 votes
Accepted

how to build a template based on the user record

To reference the target user record, I should use {!Target_User.[FIELD]} where [FIELD] is the field name. Link
user avatar
  • 5,176
4 votes
Accepted

Receiving_User merge field problems in a single user email template

Salesforce support told me the following: For portal users, the Receiving_User is actually pulling fields from the Contact object, not from the User object. Even the standard fields are from the ...
user avatar
  • 6,385
4 votes

Pulling Merge Fields that contain HTML into an email template

If you use a Visualforce Email Template, you can use <apex:outputText value="{!Object.Field__c}" escape="false"/> You cannot do it without using a Visualforce Email Template
user avatar
4 votes
Accepted

Error: Unknown property 'API.Session_ID' referenced in Links

The variable API is actually $Api. Note that this variable is case sensitive, and must have the $.
user avatar
  • 434k
4 votes
Accepted

Remove newline characters from address merge field

Use JSENCODE Encodes text and merge field values for use in JavaScript by inserting escape characters, such as a backslash (), before unsafe JavaScript characters, such as the apostrophe ('). ...
user avatar
4 votes
Accepted

What are merge fields in Apex and why are the called so?

A "merge field" simply means an area (the "field") where output from a function or expression is "merged" into the final output. In other words, the source code is basically a template, and some parts ...
user avatar
  • 434k
3 votes
Accepted

Using {!User.FirstName} in Email template aiming for User object but return current user

I resolved this issue. From the Email Template Editing page, there is an "Available Merge Fields". From that panel, people can choose whatever merge field for the Email template. Here for my usage, ...
user avatar
3 votes
Accepted

Ability to create a formula field that concatenates when data in input to a field

Yes it is possible, you would need to combine the following types of functions: IF(logical_test, value_if_true, value_if_false) and replace logical_test with the expression you want evaluated; ...
user avatar
  • 10.4k
3 votes
Accepted

Merge field not populating in Email Template

It is a weird issue, but it got fixed when I cloned the email template and used it in the workflow's email alert instead of the old email template. This seems to be a bug, as the new email template is ...
user avatar
  • 218
3 votes
Accepted

Wrong merge fields in Email Template

I just created an email template and a custom text field Case.Type__c and can confirm that the custom field "hides" the standard field. Surprising. The simplest work-around is to ensure that the ...
user avatar
  • 130k
3 votes
Accepted

Why does Messaging.renderEmailTemplate() return a "Field Custom_Field__c does not exist" even when the field does exists?

I think I found the issue, based on your assert I assume you are trying to get the bank__c info related to Submission__c in the unrendered string. Change 'Dear {!Bank__c}...' to 'Dear {!Submission__c....
user avatar
  • 16.5k
3 votes
Accepted

Email Template Community test email

After some trying I found that when you test the email template via "Send test and verify merge fields" you cannot test any community merge fields like {!Community_Url}. You need to test "live" in the ...
user avatar
3 votes
Accepted

How to control the fields displayed on Contact merge

Most fields are only displayed if they have a value in them (contact information such as emails and phones are always shown). Fields are made editable only if the user has Edit access to the field and ...
user avatar
  • 434k
2 votes
Accepted

How could {!Contact.FirstName} work on email template used for Lead Record Creation

OK, here is the answer - it is in the SFDC Help doc here: https://help.salesforce.com/HTViewHelpDoc?id=merge_fields_email_templates.htm&language=en_US Templates with contact merge fields can be ...
user avatar
  • 62.5k
2 votes

How can I use site field in an email template?

You forgot the dollar sign in your Site-variables, please replace your code with: <br/>tld: {!$Site.TopLevelDomain} <br/>upp: {!$Site.UrlPathPrefix} <br/>id: {!$Site.Id} <br/>...
user avatar
2 votes

Dynamically generated link in an email template

You can use merge fields in the "link" modal. Just write out the text you want to be a link, select it and click the "link" button. In the URL you can paste a URL that includes ...
user avatar
2 votes
Accepted

Email template merge fields not populating when sent via Apex

Looks like when one uses an email template it has to be tied to a contact. In order to do that i would just create a temporary contact as proscribed in the following SO answer: Passing custom string ...
user avatar
  • 906
2 votes

merge boolean variable works on output, not in input in VF Page

Look at the docs: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_inputCheckbox.htm the attribute type for value is object, you are passing boolean instead of an ...
user avatar
  • 16.5k
2 votes

Merge field not populating in Email Template

I faced this crazy issue when I copy+pasted the merge field from one environment sb to another. It got fixed when i copied the field from the 'Copy Merge Field Value' text box from the 'Available ...
user avatar
2 votes
Accepted

Configurable Fields that can be showed on visualforce page

What I would suggest, probably the easiest and quickest way to do this, is to add all the fields that you want to display on the page, into a field set. Then you can easily reference that field set in ...
user avatar
2 votes

Using {!User.FirstName} in Email template aiming for User object but return current user

Use the ReceivingUser variable instead of the User variable; the ReceivingUser parameter is the user being addressed, while User is the person sending the email.
user avatar
  • 434k
2 votes
Accepted

Rerender Error, with controller extension

Don't use a merge field for your rerender attribute. Just use a literal value. Incorrect: reRender="{!covenanttable}" Correct: reRender="covenanttable" When you use a merge field, the markup then ...
user avatar
  • 143k
2 votes

Can I add merge fields to the 'setplainTextBody' before I send out email?

You should look at the setTreatBodiesAsTemplate method. Optional. If set to true, the subject, plain text, and HTML text bodies of the email are treated as template data. Example usage: Messaging....
user avatar
  • 143k
2 votes

What merge field can we use in an email template to get the Instance needed to generate a URL to an internal knowledge article?

There's an ancient "API version substring" hack described for example on https://developer.salesforce.com/forums/?id=906F000000096wuIAA, experiment with it a bit? If it won't work in the email ...
user avatar
  • 23.6k
2 votes
Accepted

Email Alerts and Merge Fields not working.

There is a checkbox on every custom object definition, "Track Activities". You'll need to ensure that the box is set on VOHLI_Leads__c so that it can be the WhatId of a Task. Your merge fields, ...
user avatar
  • 87k
2 votes

Merging subscriberkeys and records

There is no way to 'merge' subscribers. Every individual Contact with a unqiue Subscriber Key also had system defined attributes which can only be changed by Salesforce Service Team and requires their ...
user avatar
  • 5,372
2 votes
Accepted

Merge field not populating

There are few things you are doing wrong. if you are Using Template, you dont have to manually add htmlBody,subject to the Single Email Message instance. As you are sending a message to contact, you ...
user avatar
2 votes
Accepted

workflow rule and email alerts firing in user context

Workflow Rules evaluate in System context. Field Updates also update in System context. Email Templates, however, honor the field security of the user, because otherwise users could render templates ...
user avatar
  • 434k
2 votes

Email Alert Triggered in Scheduled flow has blank merge fields for Custom fields Only

Don't know if anyone is following this one still but I had the same issue with a visualforce email template missing some merge fields values when sending an email alert via an scheduled-triggered flow....
user avatar

Only top scored, non community-wiki answers of a minimum length are eligible