Follow the wizard to create Visualforce email template from: Setup | Communication Templates | Email Templates | New Template and select Visualforce in Step 1 "Choose the type of email template you would like to create". You will get a basic Visualforce email template with Subject, Recipient Type (Contact, Lead, or User), and Related To Type Object.
<messaging:emailTemplate subject="Account Name" recipientType="User" relatedToType="Account">
<messaging:plainTextEmailBody >
Congratulations!
This is your new Visualforce Email Template.
</messaging:plainTextEmailBody>
</messaging:emailTemplate>
Few simple things you can modify the email template without programming:
1. Change subject to include merge field
Example: <messaging:emailTemplate subject="Account Name" recipientType="User" relatedToType="Account">
to
<messaging:emailTemplate subject="Account Name - {!relatedTo.Name}" recipientType="User" relatedToType="Account">
2. Add a ReplyTo address
Example: <messaging:emailTemplate subject="Account Name - {!relatedTo.Name}" recipientType="User" relatedToType="Account">
to
<messaging:emailTemplate subject="Account Name - {!relatedTo.Name}" recipientType="User" relatedToType="Account" replyTo="support@acme.com">
3. Change Email format from Text to HTML
Example: <messaging:plainTextEmailBody > to <messaging:htmlEmailBody >
4. Add new line
As this is now HTML email, you can add <br/> for new line.
5. You can add recipient name
Example: <p>Dear {!recipient.name},</p>
6. You can add related field, including custom field
Example: Account Owner: {!relatedTo.CreatedBy.Name}<br/><br/>
7. You can add full URL as email body
Example: URL detail: <a href="{!LEFT($Api.Partner_Server_URL_370, FIND(".com/",$Api.Partner_Server_URL_370)+3)}/{!relatedTo.Id}">{!relatedTo.Name}</a>
8. You can add logic to include field
Example: <apex:outputPanel rendered="{!relatedTo.RecordType.Name='Customer' || relatedTo.RecordType.Name='Alumni'}">
Total Revenue: {!relatedTo.Total_Revenue__c}<br/><br/>
</apex:outputPanel>
Sample of complete email template:
<messaging:emailTemplate subject="Account Name - {!relatedTo.Name}" recipientType="User" relatedToType="Account" replyTo="support@acme.com">
<messaging:htmlEmailBody >
<p>Dear {!recipient.name},</p>
Account Owner: {!relatedTo.CreatedBy.Name}<br/><br/>
<apex:outputPanel rendered="{!relatedTo.RecordType.Name='Customer' || relatedTo.RecordType.Name='Alumni'}">
Total Revenue: {!relatedTo.Total_Revenue__c}<br/><br/>
</apex:outputPanel>
URL detail: <a href="{!LEFT($Api.Partner_Server_URL_370, FIND(".com/",$Api.Partner_Server_URL_370)+3)}/{!relatedTo.Id}">{!relatedTo.Name}</a>
</messaging:htmlEmailBody>
</messaging:emailTemplate>
For advance page with apex controller, you can use Visualforce Component, and use apex class as Controller.
Example: <c:AccountNotification AcctId="{!relatedTo.Id}"/>
In the component specify the apex class as controller
<apex:component controller="AccountEmailNotify" access="global">
</apex:component>
Reference:
Pages
Thursday, July 7, 2016
Friday, June 24, 2016
Salesforce: Show value only to Owner and Manager
Use case:
A scoring system has been implemented to auto calculate if a lead is valid to pursue. But, the score should only visible to the record owner manager.
In Salesforce, we only can set field visibility using Field Level Security (FLS) which is based on Profile. But record owner manager have the same profile with the record owner, and the manager may owned a lead which he supposed not able to see the score, only the manager's manager able to see it.
Solution:
1. Set the score field not visible from all Profile with FLS
2. Create a formula field and make it visible to all Profile
IF( $User.Id = Owner.ManagerId, Score__c, null)
For other scenario, if only the owner and owner's manager should be able to see the score, use this formula:
IF( $User.Id = OwnerId || $User.Id = Owner.ManagerId, Score__c, null)
Salesforce Change Set
- Action
- Action Link Group Template
- Apex Class
- Apex Sharing Reason
- Apex Trigger
- App
- Approval Process
- Assignment Rule
- Auth. Provider
- Auto-Response Rule
- Button or Link
- CORS Whitelist Origin
- Call Center
- Communication Channel Layout
- Compact Layout
- Custom Console Component
- Custom Field
- Custom Label
- Custom Metadata Type
- Custom Object
- Custom Permission
- Custom Report Type
- Custom Setting
- Dashboard
- Dataflow
- Document
- Email Template
- Escalation Rule
- External Data Source
- Feed Filter
- Field Set
- Flow Definition
- Folder
- Global Picklist
- Group
- Home Page Component
- Home Page Layout
- Language Translation
- Letterhead
- Lightning Component Bundle
- Lightning Page
- List View
- Matching Rule
- Name Credential
- Opportunity Split Type
- Page Layout
- Permission Set
- Platform Cache Partition
- Post Templates
- Queue
- Record Type
- Remote Site
- Report
- Reporting Snapshot
- Role
- S-Control
- Send Action
- Sharing Criteria Rule
- Sharing Owner Rule
- Sharing Territory Rule
- Site.com
- Static Resource
- Tab
- User Provisioning Config
- Validation Rule
- Visualforce Component
- Visualforce Page
- Workflow Email Alert
- Workflow Field Update
- Workflow Outbound Message
- Workflow Rule
- Workflow Task
- Zone
Note:
Search Layouts is not available as independent Component in Change Set, but when you deploy the object, all Search Layouts for that object is included.
For Custom Settings, you need to re-create or export/import (e.g. using Data Loader) the data set/values in the target org, Change Set will only deploy the Custom Setting shell.
Custom Fields from Custom Settings will be treat as per normal Custom Fields from object.
The components available for a change set vary by edition. Some components require corresponding features to be enabled in your organization, such as: Sharing Territory Rule will not available if Territory is not enabled.
If you create or modify components that are not available in a change set, you can't send those components from one organization to another in a change set. In this case, migrate the changes manually by repeating the steps you performed when you created or modified the component.
List Views are visible to all users when you deploy a change set. Change the visibility in the destination organization as necessary. See more information related to List View for change set here List View not visible in Change Set.
Deployed custom tabs are hidden by default for all users. They’re visible only if the change set also contains profiles that set the visibility property appropriately. Professional Edition organizations are an exception—deployed custom tabs in those organizations are always visible by default.
Reference:
Friday, June 10, 2016
Salesforce: Convert Multi-Select Picklist to Text
More than a year ago, we blog about How to sort Multi-Select Picklist in View? This blog will share about how to convert Multi-Select Picklist to Text, so you can use it in many areas.
As of now (Summer '16 release), multi-select picklist only support following functions:
- INCLUDES()
- ISBLANK()
- ISNULL()
- ISCHANGED() - only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited.
- PRIORVALUE() - only in assignment rules, validation rules, workflow field updates, and workflow rules in which the evaluation criteria is set to Evaluate the rule when a record is: created, and every time it’s edited.
With a simple formula field return text format, you can get the multi-select picklist values in Text.
Let say you have a custom multi-select picklist field called Country__c with 5 values. Here is the formula:
IF( INCLUDES(Country__, 'Singapore'), 'Singapore,', null) +
IF( INCLUDES(Country__, 'Indonesia'), 'Indonesia,', null) +
IF( INCLUDES(Country__, 'Malaysia'), 'Malaysia,', null) +
IF( INCLUDES(Country__, 'China'), 'China,', null) +
IF( INCLUDES(Country__, 'Japan'), 'Japan,', null)
Reference: Tips for Working with Picklist and Multi-Select Picklist Formula Fields
Thursday, June 9, 2016
Salesforce System Status Alert with IFTTT
Salesforce Trust - http://trust.salesforce.com is the main area to monitor if any issues happened with your Salesforce org, but you need to know what is your Salesforce instance, for production instance, it start with NAxx, EUxx, and APxx, while CSxx for sandbox instances.
It is a good idea to have central place to monitor all instances, or your specific instances. For this blog I'll use sample instance NA17. We'll not always keep monitor that website - http://trust.salesforce.com/trust/instances/NA17, but I expect that Salesforce Trust will email me directly if any post related to my instance.
Solution: because Salesforce Trust also publish RSS feed, we can use this and combine with IFTTT.com to trigger send email. The same result can be achieved using other tools support rss feed to email such as: blogtrottr.com, but for this blog, we'll just use IFTTT.com
RSS Feed for NA17 = http://trust.salesforce.com/rest/rss/NA17
If any post related to NA17, IFTTT will send you email, see sample below:
It is a good idea to have central place to monitor all instances, or your specific instances. For this blog I'll use sample instance NA17. We'll not always keep monitor that website - http://trust.salesforce.com/trust/instances/NA17, but I expect that Salesforce Trust will email me directly if any post related to my instance.
Solution: because Salesforce Trust also publish RSS feed, we can use this and combine with IFTTT.com to trigger send email. The same result can be achieved using other tools support rss feed to email such as: blogtrottr.com, but for this blog, we'll just use IFTTT.com
RSS Feed for NA17 = http://trust.salesforce.com/rest/rss/NA17
- Login or Signup to ifttt.com
- Create a Recipe
- Select if "Feed"
- Enter NA17 Feed URL: http://trust.salesforce.com/rest/rss/NA17
- Select then "Email"
- Leave the Subject and Body as default
- Done and you have your recipe running.
If any post related to NA17, IFTTT will send you email, see sample below:
Thursday, May 26, 2016
Salesforce: Multi-Person Calendar Event (User as invitee)
In previous blog Multi-Person Calendar Event (Contact / Lead as invitee), we discussed about adding contact or lead as invitee, we also discussed the structure at the backend and how we can use API to add contact or lead as invitee.
But, when the invitee is a user, the structure will be a little different, although the objects used is the same.
1. Event object
Instead of create only 1 event record as add contact/lead as invitee, invite user will create multiple event record based on number of invitee + sender. In this scenario, we are going to invite 2 users and 1 contact.
Sample query: Select Id, Subject, OwnerId, GroupEventType, IsChild, WhatId, WhoId, CreatedDate, ActivityDate, ActivityDateTime, StartDateTime, EndDateTime, EventSubtype, IsReminderSet, Type, WhatCount, WhoCount FROM Event WHERE Subject = 'Test with User'
This will create 3 events with same subject, one event for each User, but only 1 with IsChild = False, which is "parent" event. Also notice that each record have different Owner Id, and all events with GroupEventType = 1, remember that we cannot populate / update GroupEventType manually.
2. EventRelation object
Sample query: SELECT Id,EventId,RelationId,IsParent,IsWhat,IsInvitee,Status,CreatedDate FROM EventRelation WHERE EventId IN ('00U63000001T8Y9EAK','00U63000001T8YAEA0','00U63000001T8YBEA0')
Notice that records created in this object is relate to: 1 opportunity, 1 contact and 2 users, but all linked to the same event, which is parent event where IsChild = False.
3. EventWhoRelation object
Same with EventRelation object, only 1 record created as we only have 1 contact relate to the event, and it is linked to the parent Event (IsChild = False)
Sample query: SELECT Id, EventId, RelationId, Type, CreatedDate FROM EventWhoRelation WHERE EventId IN ('00U63000001T8Y9EAK','00U63000001T8YAEA0','00U63000001T8YBEA0')
How to auto add User as Invitee Event with API?
You just need to insert record(s) to EventRelation object, 1 record for 1 contact / lead. Here are fields you need to populate:
1. EventId = Event Id
2. RelationId = User Id
3. IsParent = False
4. IsWhat = False
5. IsInvitee = True
6. Status = New
But, when the invitee is a user, the structure will be a little different, although the objects used is the same.
1. Event object
Instead of create only 1 event record as add contact/lead as invitee, invite user will create multiple event record based on number of invitee + sender. In this scenario, we are going to invite 2 users and 1 contact.
Sample query: Select Id, Subject, OwnerId, GroupEventType, IsChild, WhatId, WhoId, CreatedDate, ActivityDate, ActivityDateTime, StartDateTime, EndDateTime, EventSubtype, IsReminderSet, Type, WhatCount, WhoCount FROM Event WHERE Subject = 'Test with User'
This will create 3 events with same subject, one event for each User, but only 1 with IsChild = False, which is "parent" event. Also notice that each record have different Owner Id, and all events with GroupEventType = 1, remember that we cannot populate / update GroupEventType manually.
2. EventRelation object
Sample query: SELECT Id,EventId,RelationId,IsParent,IsWhat,IsInvitee,Status,CreatedDate FROM EventRelation WHERE EventId IN ('00U63000001T8Y9EAK','00U63000001T8YAEA0','00U63000001T8YBEA0')
Notice that records created in this object is relate to: 1 opportunity, 1 contact and 2 users, but all linked to the same event, which is parent event where IsChild = False.
3. EventWhoRelation object
Same with EventRelation object, only 1 record created as we only have 1 contact relate to the event, and it is linked to the parent Event (IsChild = False)
Sample query: SELECT Id, EventId, RelationId, Type, CreatedDate FROM EventWhoRelation WHERE EventId IN ('00U63000001T8Y9EAK','00U63000001T8YAEA0','00U63000001T8YBEA0')
How to auto add User as Invitee Event with API?
You just need to insert record(s) to EventRelation object, 1 record for 1 contact / lead. Here are fields you need to populate:
1. EventId = Event Id
2. RelationId = User Id
3. IsParent = False
4. IsWhat = False
5. IsInvitee = True
6. Status = New
This is similar with add Contact / Lead as invitee, the difference is: Salesforce will auto create event record for the user as child record, if the parent record initially is not for multi-person, GroupEventType will change from 0 to 1.
Subscribe to:
Posts (Atom)








