Saturday, December 26, 2015

Salesforce: Change Record Owner

In general, to transfer a record from a user to you or to someone else in Salesforce, you need to have following access or permission:
  • you are the record owner and you have Edit permission on the object, or
  • record owned by a user under you in the role hierarchy (Grant Access Using Hierarchies must be enabled for that object) and you have Edit permission on the object, or
  • you have Transfer Record permission and Edit permission on the object, or 
  • you have Modify All permission for the given object, regardless of who owns the record, or
  • you have Modify All Data permission, regardless of who owns the record.
If you see above criteria's, having edit access on a record doesn't mean you will be able to transfer a record you can edit. If you click Sharing button on the record, it will show the explanation of Access Levels:
  • Full Access - User can view, edit, delete, and transfer the record. The user can also extend sharing access to other users.
  • Read/Write - User can view and edit the record, and add associated records, notes, and attachments to it.
While using sharing rules in OWD, we cannot share object access to Full Access.

Transfer Record Permission
For a user with Transfer Record permission, but no Edit permission on record (not on the object):
- will be able to change the owner from Change Owner link from record page
- will be able to change the owner from list view (for Lead and Contact)
- will be able to mass transfer record using "Mass Transfer Records" from the setup menu

With this, it is clear that transfer record owner does not relate with edit record permission, but related with edit object permission.

Summary: user with "Transfer Record" permission allowed to transfer ALL records, as long as the user has Edit permission to the object. Read again here "edit on object" NOT "edit on record", this means, the user will be able to transfer record owner even user do not have Edit access to that record.

Transfer Record permission will include Transfer Case and Transfer Lead permission.

A special case to transfer Campaign, users must also have the "Marketing User" checkbox selected on their user record.

Use Case: allow a user to change owner as long as the user has edit access to the record, edit access may be given from OWD sharing rules or manual sharing.

Solution: based on the above criteria, this use case doesn't fit any criteria. In short, we need to customize with write trigger to query to object UserRecordAccess, example: SELECT RecordId, HasEditAccess FROM UserRecordAccess WHERE UserId='00590000000OoB0AAK' and RecordId='00690000005vUbw' and "Transfer Record" permission must be given to that users.

Other Solution: this may be not an ideal solution, but if you do not have developers to write a trigger, you can use validation rules based on conditions from user object, example: users located in West area only allowed to transfer record owned by users in the same West area, sample validation rule:
TEXT($User.Area__c) <> PRIORVALUE(Owner.Area__c) || 
TEXT($User.Area__c) <> Owner.Area__c 

** this validation rule will stop user to edit record if the record owner is not in the same Area with the user, or the prior record owner is not in the same with user's Area.

Blog last modified date: 23 Oct 2016

How to log Case to Salesforce support

Two months ago (around late Oct 2015 - after Winter '16 release), Salesforce change Help and Training portal to a whole new experience. There are 4 main areas improvement in the new portal:
1. Mobile friendly: open web browser from Tablet and smart Phone.
2. My Success Hub: Dashboard, Open and Closed Cases, Training, and Contact Us.
3. Help Finder: Step by Step guided experience with answers at every corner, this is good for user to have self-service.
4. Auto complete Search: based on multiple sources, portal will auto complete and recommend question you may ask.

But, somehow for experience admins or consultants who familiar with the system, to log a case become another challenge. In earlier new version, it buried somewhere under "click here" link - explained by this article Submit, create or update a case with Salesforce Support. This week (before Christmas 2015), we see a newer version released again (2 months after initial portal released), so above article become no longer valid.

So, as of today 26 Dec 2015, here is the step by step on how to log Case to Salesforce support. After click Help & Training link at top right in

1. Click Contact Support

2. Select a Topic

3. Select a Category

4. Log a Case 
You will see Log a New Case big icon, if you do not see that icon here, it may depend on your level support or Category you choose, you may not see the icon here, continue to step 5 below.

5. Select a Question 
If you do not see the icon at step 4, click a Question (in gray cell), this will bring you to Solution tab. Look for the icon below.

If you not so happy with the new portal, feel free to vote for this idea to have easier way to log a Case, maybe from My Success Hub.


Wednesday, December 23, 2015

Salesforce: Sending email using other email address

In previous blog, we discussed about issue with in Microsoft Outlook when Sender ID compliance is enabled. In this blog, we would like to discuss if Salesforce users need to send email as other email address or a team mailbox from Salesforce.

This is standard Send an Email screenshot:

There are 2 options to send email using other email address:

1. My Email Settings
This is option is more for personal usage or need to do by each users if need to do by a team.
  • Navigate to Your Name | My Settings | Email | My Email Settings
  • Change "What email address would you like to use as your return address?" to the new email address.

Salesforce will send an email for verification to that email address and you need to click the link in that email.

Once verification done, you will notice there are option for you to select a sender email address when compose email from Salesforce, so when recipient reply the email, it will sent to which email address you select.

2. Organization-Wide Email Addresses
This option is for setting additional email address for whole Salesforce users or by Profiles.
  • Navigate to Setup | Email Administration | Organization-Wide Addresses
  • Add Display Name, Email Address, select either visible for all users (All Profiles) or certain Profiles only.

Same with My Email Settings (point 1 above), Salesforce will send email for verification before it will be available to users.

Once verified, notice additional email available in From when you Send Email from Salesforce.

Salesforce: on behalf of

When you send email from Salesforce, for recipient open the email sent with Microsoft Outlook, the may see the sender as on behalf of Sender FirstName LastName <> rather than your name and your email address.

But, when recipient hit reply in Microsoft Outlook, it will point the email to "the right email address" of the sender, not to

When recipient open the same email not with Microsoft Outlook, example: using, the sender " on behalf of" is not there. Salesforce is not adding that into the email, that is caused by the email client, which is specific to Microsoft Outlook. Below is screenshot from other email client:

To remove " on behalf of" follow these steps:
  • Click on Setup | Email Administration | Deliverability 
  • Locate the Email Security Compliance section
  • Unselect the Enable Sender ID compliance box 
  • Click Save button

The emails you send will no longer include the " on behalf of".

This is how it looks when open from other email client (such as:, notice there are no differences before and after we change Sender Id compliance.


Friday, December 18, 2015

Salesforce: Win/Loss Ratio

Win/Loss Ratio is always interesting number for a company, by region, by country, until be area manager in a country. It can be either by opportunity quantity or by opportunity amount. In common platform, you need to hire developer to achieve this ratio, developer need to write complex coding, but with Salesforce, as admin, we can create normal report and use Custom Summary Formula with very minimal effort.

The report format need to be Summary, Matrix or Joined report. Side note: you can only add up to 5 Custom Summary Formula in a report.

Here are widely use formula in report related to Opportunity:
  • WON:SUM - number of opportunity Won
  • CLOSED:SUM - number of opportunity Closed (Won + Lost)
  • AMOUNT:SUM - total Amount of opportunity 
  • Record Count - number of record per group

1. Use Case: count Win Loss Ratio by Quantity

2. Use Case: count Win Loss Ratio by Amount

* Win / Loss here is a formula field for report display purpose - this is the formula IF(IsWon, "Win","Lost")

Salesforce: Lead Source fields

When adding new Contact or Lead to a CRM system, you would like to note how you get know to that person? That's why by default Salesforce provide standard field or Lead Source is 4 main objects below, and they are picklist fields. You can customize the values based on your organization business model.
  1. Lead - Lead Source
  2. Account - Account Source
  3. Contact - Lead Source
  4. Opportunity - Lead Source
Over the time, you may modify the lead source values accordingly, but to note that: the values of 4 fields above in 4 objects above are in sync, this mean, if you add a new Lead Source value in Lead, it will copy to other objects, the same when you edit, delete and re-order values.

When you convert a Lead to Account, Contact and Opportunity, the conversion value of Lead Source from Lead will bring to Contact and Opportunity Lead Source.


Wednesday, December 16, 2015

Salesforce: Assigning Price Book

As in our previous blog Getting Started with Objects related to Salesforce Product, we mentioned that each Opportunity or Quote only link to one Price Book, but can we have configure that not all users able to use all active Price Book?

Yes, we can configure a Price Book to be available by Users, Groups, Roles, Roles and Subordinates, but we not by Profiles.

Here we go:
1. Configure Price Book sharing to "No Access"
Navigate to Setup | Security Controls | Sharing Settings, click Edit button, look for Price Book and change to No Access. By default, Price Book access is "Use".

2. Share the Price Book
Once Price Book sharing setting set to No Access, open the price book and you should see Sharing button in the Price Book page. Click Sharing button, it will show existing User and Group Sharing (if any). Click Add button  to share the price book, and make sure Price Book Access set to Use.


Salesforce: Getting Started with Objects related to Salesforce Product

Product is not new features in Salesforce, it has been there for long time and widely used. I see many companies using Sales Cloud, but not use Product. In this blog, I would like to introduce how Product work in Salesforce, from the basic.

1. You can rename it
Some company do not like it called as Product, because not suit to the business terms for the company. As admin or consultant, you can rename it as Service, or Opportunity Line.
  • Go to Setup - CustomizeTab Names and Labels Rename Tabs and Labels
  • Looks for Products and click Edit link prior to it.
  • You need to enter Singular and Plural name, in this blog, I'll use Opportunity Line
  • Click Save to finish, or Next if you would like to change field label related to Product, by default all "Product" field labels has been rename to "Opportunity Line" for Standard and Other field related to Product.

This will change all label in Salesforce user interface from Product to Opportunity Line, from: Related List name, Tab name, Report Type name, Field name in report, and etc, except the one related with API name and not visible by end user directly, such as: Workflow, Validation Rule, and so on.

Sample of the change happened in related list in Opportunity page layout.


2. Product is a special object
  • It is not the same with other standard object or custom object, Product is linked to Opportunity and Quote through Price Book.
  • Each Product added into Opportunity in an object called Opportunity Product, so this object would be a junction object. For Product added into Quote called Quote Line Items.
  • You can create roll-up summary field from Opportunity Product to Opportunity, and from Quote Line Items to Quote.

3. Product Object
  • The API name is called as Product2, with object prefix 01t
  • To directly access Products tab from Salesforce user interface, go to ; change na3 to your Salesforce instance. 

4. Price Book Object
  • You can have multiple price books in Salesforce, each price book may contain different Product and can have different List Price.
Example: a product available in EMEA price book may not available in APAC price book, but available in AMER price book. However, the List Price for AMER price book can be different with EMEA price book.
  • The API name is Pricebook2, with object prefix 01s
  • User with read access to Product and Price Book, user can access Price Book from Price Books tab or directly go to ; change na3 to your Salesforce instance. 
  • Each Opportunity or Quote only link to single Price Book. 
  • If there is only a single price book is active, or the user only has Use permission to a one price book, then that price book is automatically selected when user adding products to Quote or Opportunity.
  • If user has Use access to more than one active price book, user must manually select a Price Book prior to adding products to Opportunity or Quote.
  • If user has Use access to more than one active price book, user able to change selected Price Book for the Opportunity or Quote, but all Products added will be removed.


Monday, December 14, 2015

Install MavensMate for Salesforce Admin

When you read this blog, MavensMate creator has decided to end development and support of MavensMate, but that does not mean we cannot use MavensMate anymore. IDE - a powerful client application for creating, modifying and deploying applications. But for some people, like my case, the IDE not really working smoothly with my office machine which is still with Windows 7 32-bit. In many times (often), it just hangs when try to select more components to the project. Some other users said that Force.IDE is so clunky and finicky. The other user looks for faster IDE at getting metadata and more user-friendly. Eclipse is slow to load and tends to get heap size limits with an org of bigger metadata size.

Recently I found another Open Source IDE for (it is free), it called MavensMate. As in their website now - it works with OSX (10.8+), Windows (Server 2008, Windows 7, Windows 8), and Linux (Ubuntu 14). Although it doesn't say Windows 10, I just try and it works well.

I read a blog say MavensMate installation for OSX is a breeze, but not for the Windows machine. I found myself takes sometimes to get this installed, the installation guide from the website is not really detail - MavensMate Getting Started.

Before I explain step by step to install MavensMate, for Salesforce Admin, IDE is not always just for developers, although it is mostly designed for that purpose. Example, with IDE you can easily search where a field used in the reports (of course not include reports in user personal folders).

1. Download Sublime Text
Use only version 3 (or above), download from here.

2. Install Package Control
Once you have Sublime Text installed successfully, go to this link to copy Python code to install Package Control to Sublime Text console.
From Sublime Text, open the console via the ctrl+` shortcut or the View > Show Console menu. Paste the Python code copied earlier and press enter, this will install Package Control. Monitor the console log until installation finish, this process should be very fast - less than 1 minute in my case.

3. Restart Sublime Text
You will need to close and open Sublime Text manually to finish Package Control installation.

4. Install MavensMate
- Open Package Control with Ctrl + Shift + P and type install 
- Select the Package Control : Install Package

- Type mavensmate and press enter 

5. Download and install Mavensmate Desktop
Because of MavensMate is no longer develop and support, you can download MavensMate Desktop from Github. There is an option for portable installation too, so you just run the MavensMate.exe file when need it.

6. Setting Workspace
Now, MavensMate is installed in your Sublime Text. Next, you need to set the workspace for the user in MavensMate. From MavensMate Desktop, select Settings, you can set the path where you want to store all files related to MavensMate project.

Make sure the path is valid and the user has full access to the path entered as a workspace.

6. New MavensMate project
From menu MavensMate | Project | New Project... system, for an unknown reason, the system may ask you to update MavensMate, navigate to  MavensMate | MavensMate API (mm) | Update MavensMate API (mm). You need to close and open Sublime Text again.
Once this done, click new project again and it should open a web browser to enter Project name and login credential, you may need to click Advanced and Project Metadata tab to make sure all metadata you need is selected.

Based on Metadata selected upon project creation page, the metadata will be shown at the left side.

You also can Edit Project to add/remove metadata selection for the project.

From here, if you would like to search for something, example: a field name, right click on project name or Ctrl + Shift + F to open search window.

The search result will be shown in the find results, from: apex class, reports, object (including field, validation rule, help text), etc based on selected metadata.


Sunday, December 13, 2015 Prospector: How to Identify?

When you subscribe for Prospector and, you can easily add person to Salesforce as Contact or Lead, and company as Account. But, overtime you need to monitor how many person and company has been added, this is also to tell on how optimize users is using

For records added from, you can query or run report on following fields:

  • " Key" field is not blank, this would be filled with digits

Contact and Lead
  • " Key" field is not blank, this would be filled with digits
  • "Lead Source" is filled with Jigsaw or

You also can install a free package from App Exchange Prospector Reports, this package will add custom report type " Users and Usage", custom field "Sourced from" in Account, Contact and Opportunity, a dashboard and reports used as data source for the reports.

Wednesday, December 9, 2015

Salesforce: State and Country Picklists

By default, State and Country is textbox field, where user can enter any data. Some organization hire developer to write trigger to validate the data entered is valid. Another option is to use AppExchange product such as AddressTools Premium or AddressTools Free.

But if you are not aware, Salesforce actually have something called State and Country Picklists, this is out of the box feature to change textbox field to picklist for both State and Country, this is applicable for shipping, billing, mailing, and “other” address fields in standard object:
  • account
  • campaign members
  • contact 
  • contract
  • lead
  • person accounts
  • quotes
  • service contracts 

When State and Country Picklists is activated, users will be not able manually to type into State and Country, but they have to select from picklist. This will make your data clean, e.g. United States maybe enter as USA, U.S., United States America, this will make you will be difficult to analyze data correctly.

How to activate this?
1. Navigate to SetupData ManagementState and Country Picklists

2. Click Configure states and countries in step 1
  • You can set default country, in case your business mostly only happened within a country. 
  • By default Salesforce will provide 239 countries and some of them have States/Provinces. For countries that you know should have State, but not available, click Edit link on that country, click New State button to add State. This manual process will take a lot of time when you need to enter many State not available out of the box.
  • You also can modify the Country Name and Integration Name. Integration Name must be unique, Salesforce uses this value to integrate new picklist values with former text-only values. It is not case sensitive. When you add new country, Country Code must be unique and you cannot modify standard country code.
  • To hide a country visible for user to select in picklist, unselect Visible checkbox

3. Click Scan Now in step 2
  • You will receive 2 emails: one regarding affected address data and one regarding affected customizations. 
  • For customizations scan result, you need to download a text file from document, this will include where State and Country used in your org: 
    • Apex Class
    • Visualforce Page
    • Apex Trigger
    • Assignment Rule
    • Auto-Response Rule
    • Email Template
    • Escalation Rule
    • Field Set
    • List View
    • Report
    • Validation Rule
    • Custom Button or Link
    • Workflow Rule
    • Matching Rule
For reports and list views, it will not include reports and list views in personal folder or visible only to a user, except it owned by user who run the scanner.
4. After get two emails above, click Convert Now in step 3
For address (state and country), you need to select the data and select a value from Change To picklist, If you do not know the right value at that moment, you can map it to "Unknown value". Users user open the record, they will see original state and country (not Unknown value), but they will encounter error to save, unless they change the state or country to a valid value before saving. You should only map to "Unknown value" when you do not know the correct value.
This step will take a lot of time to clean up invalid data manually.

5. Once conversion process finish, you will be able to click Enable button at step 4 Turn on state and country picklists.

1. If you change a country name at step 1, the original name will be shown in Change To picklist when you convert state or country to picklist, just select the original name, and it will use value renamed, example: Viet Nam to Vietnam. This maybe a Salesforce defect, but not a blocker.

2. Notice two new fields created for all objects with standard address field, which is BillingCountryCode and BillingStateCode.

Before enable state and country picklist:

After enable state and country picklist:

3. From the last screenshot above taken from SOQL query, invalid value converted to 'Unknown value' will not have value in the Code field. For valid values, code will be auto populated with the Country Code and State Code.

4. When we run report, we can see the old value with suffix (text only)

5. When you open existing report with state or country, it will prompt you to update the report with new picklist field.

But, if you do not have permission to edit the report, here is the screenshot.

Effect with Insert / Update (integration or mass loader)
  • So which field should I use? BillingCountry or BillingCountryCode or both? You can provide only one value, either name or code, and the other value will be auto populated by the system. But if you populate both for some reason, make sure the code is align with the country name, otherwise the insert/update process will be failed. The same goes for State.
  • The country / state name or code must be exist in the picklist value defined, otherwise the insert/update process will be failed. 
  • When you insert / update State, make sure that state is available for that particular country, otherwise the process will failed.

So this is how it looks like when you had State and Country Picklists enabled. Notice both Country and State is a picklist, and State picklist value is depend on Country selected.


Tuesday, December 8, 2015

Salesforce: Export non-English characters

We wrote a blog sometimes back on how to import data with non-English characters into Salesforce - Mass upload/insert non-English characters to Salesforce. UTF-8 encoding play important role when working with  non-English characters.

Salesforce by default support multi languages, so your user may enter data in their local language. When user run a report, it will show in the correct local language as well.

But, when user click Export Details to export into Excel file, it maybe shown as ???

This may caused by wrong selection of Export File Encoding, to support Non-English characters, make sure to select Unicode (UTF-8) when you export data export into excel.

Screenshot below would be the correct result exported to Excel file.

Sunday, December 6, 2015

Salesforce: Mass Update from List View using JavaScript

Sometimes back, we discussed on how to update Salesforce with JavaScript from a button in a page layout. Next, recently we have issue on how to replicate the same for many records to mass update from list view? Inline Editing in one the option to mass update records from a list view, read this blog for more information on how to use inline editing in list view.

But how about if we always need to mass update with the same data? It can be for only 1 field or for multiple fields, example: update Account type to Customer. Using inline editing may not always be the best option with all the limitations of inline editing.

We can use similar approach of using JavaScript to mass update many records from list view.
1. Create custom button with Java Script
2. Add the button to list view

For this blog, we will use scenario to mass update Account type to Customer.

1. Create custom button
  • Navigate to Setup | Customize | AccountsButtons, Links, and Actions
  • Click New Button or Link
  • Enter Label, select Display Type = List Button and enable Display Checkboxes (for Multi-Record Selection), Behavior = Execute JavaScript, Content Source = OnClick JavaScript
  • Copy and paste following script
 var records = {!GETRECORDIDS($ObjectType.Account)};   
 var updateRecords = [];   
 if (records[0] == null)   
  alert("Please select at least one Account")   
  for (var i=0; i<records.length; i++)   
   var acc = new sforce.SObject("Account"); = records[i];   
   acc.Type = "Customer";   
  result = sforce.connection.update(updateRecords);   
  window.location.href = "/001";   

2. Add the button to list view
  • Navigate to Setup | Customize | Accounts | Search Layouts
  • Click Edit on Accounts List View
  • Select the custom button created and move it to the right on Selected Buttons
  • Save and done

Note: if the record unable to save for some reasons, maybe validation rule, the error message will NOT display and user may not aware. But, admin can debug this with Debug Log.

This operation will consider as "Api" with Application pointing to the custom button id.

Page-level ad