Tuesday, September 30, 2014

Salesforce: How to sort Multi-Select Picklist in View ?

Multi-Select Picklist is a great feature for user to select multiple values controlled. You can use the multi-picklist field in View, Report, etc.

Recently we have issue when used it in View, user not able to sort b value using this multi-select picklist field. A quick idea is to create a text formula field, but looking at multi-select picklist fields can only be used in these functions: INCLUDES(), ISBLANK(), ISNULL() for formula field, TEXT() is out of picture here.

ISCHANGED() and 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.

Create text formula field with INCLUDES()
 IF( INCLUDES( Country__c, 'Singapore'), 'Singapore',  
     IF( INCLUDES( Country__c, 'Australia'), 'Australia',  
         IF( INCLUDES( Country__c, 'Malaysia'), 'Malaysia',  
             IF( INCLUDES( Country__c, 'Thailand'), 'Thailand',  
                 IF( INCLUDES( Country__c, 'Hong Kong'), 'Hong Kong', 'Other')  

Cons: when you have multiple values in the field, it will return based on the first value match.

ReferenceTips for Working with Picklist and Multi-Select Picklist Formula Field

Sunday, September 28, 2014

Salesforce: Long Text Area formula field

As of Winter '15 release, when you use function LEN() with Long Text Area field, you will get error message Error: You referenced an unsupported field type called "Long Text Area" using the following field:. The same error when you use it with Rich Text Area field, it also happen when you use those fields with other formula such as: MID(), FIND(), BEGINS(), CASE() and etc.

This limitation has been voted in AppExchange with 3470 points currently, please vote this idea.

Workaround: create Workflow Rule with Field Update action

Example: we would like to count length of Description field with Case

1. Create Custom Number Field
  • Setup | Customize | Cases | Fields 
  • Click New button in Case Custom Fields & Relationships
  • Select Number and Next
  • Enter Label, Length and Description
  • Click Next to continue and follow the wizard to save

2. Create Field Update for Workflow Rule
  • Setup | Create | Workflow & Approvals | Field Updates
  • Click New Field Update button
  • Enter Field Update Name, Description
  • Select Case object, and above field created
  • Choose Use a formula to set the new value 
  • Enter the formula into Formula Editor: LEN(Description)

3. Create Workflow Rule
  • Setup | Create | Workflow & Approvals | Workflow Rule
  • Click New Rule button
  • Select Case object
  • Enter Workflow Name, Evaluate the rule when a record is = created, and every time it’s edited
  • Rule Criteria = True

Click Next to continue then choose Select Existing Action in Immediate Workflow Actions, select field update action created in step 2 above. Save and remember to Activate to Workflow.

Cons: as workflow will only fired when there is update occur to the object, otherwise the value for that custom number field will be blank. To make it all populated, you need to mass update the object for all records.

Tuesday, September 23, 2014

Visualforce Area for Home Page Custom Component

By Summer '15 release, Home Page Custom Component contains code will no longer supported. Salesforce will remove non-supported code from HTML Area home page components. As a result, components with JavaScript or other advanced HTML elements may stop working properly.

Salesforce advise to use Visualforce Area to replace it, so if you have any exisiting HTML Area component, convert them Visualforce Area. You need to add the new component (and remove HTML Area components) to all Home Page Layouts.

Example: this is your HTML in HTML Area component
<marquee><b style="color: rgb(204, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: medium;">Salesforce will be conducting emergency maintenance tonight, 14-Oct-14, from 7:00-8:00PM Pacific Time.&nbsp; will not be available during this time.&nbsp; We extend Salesforce's apologies for this inconvenience.</b></marquee>

1. Create Visualforce page
Setup - Develop - Pages (you can create new Visualforce page directly in Production (although you should built it in Sandbox for testing and approval, and do not need Apex Test Method to deploy from Sandbox instance)

2. Copy the HTML
Put the HTML from existing component into <apex:page>HTML</apex:page> and Save.
1:  <apex:page>   
2:  <marquee>   
3:  <b style="color: rgb(204, 0, 0); font-family: Arial, Helvetica, sans-serif; font-size: medium;">Salesforce will be conducting emergency maintenance tonight, 14-Oct-14, from 7:00-8:00pm Pacific Time.&nbsp; will not be available during this time.&nbsp; We extend Salesforce's apologies for this inconvenience.</b>   
4:  </marquee>   
5:  </apex:page>   
3. Create Home Page Components
  • Setup - Customize - Home - Home Page Components, type a name and select Visualforce Area
  • Choose Visualforce Page created above.
  • Set the height, tick Show scrollbars and Label as needed.
  • Save

4. Set Home Page Layouts
  • Setup - Customize - Home - Home Page Layouts
  • Edit each Home Page Layout,  you should see new Visualforce Area component created in Components to Show, enable that component
  • Next
  • Adjust the order Up / Down
  • Save

How to enable Salesforce1 access by Profile / User?

By default, all users able to login to able to login to Salesforce1 mobile app. But, can we control Salesforce1 app only for some users or by user profiles?  YES, here we go:

1. Setup Connected Apps
  • Setup - Manage Apps - Connected Apps, select both Salesforce1 for iOS and Salesforce1/Chatter for Android as user may use both devices.
  • Click Edit next to Salesforce1 for iOS
  • Change Permitted Users under OAuth policies from All Users may self-authorize to Admin-approved users are pre-authorized
  • To enhance security, you can enable PIN under Mobile Integration in this page
  • Save
  • Repeat the same for Salesforce1/Chatter for Android

2. Enable Profiles or Permission Sets
  • Once step 1 above done, click on Salesforce1 for iOS & Salesforce1/Chatter for Android link (not Edit link)
  • You will notice Profiles & Permission Sets related list added (this is because Permitted Users now is set to Admin-approved users are pre-authorized)
  • Click Manage Profiles or Manage Permission Sets button 
  • Select Profiles or Permission Sets to enable
  • Save
You can do the same from Profile page as well, look for Connected App Access section, then enable Salesforce1/Chatter for Android and .

The same for Permission Set:

When Permitted Users set to All Users may self-authorize, user will see below screen to self approve

Once it change to Admin-approved users are pre-authorized, for user not in the approved list, user will see error below:

You can monitor user login using Salesforce1 from Login History, see Application column.

Note: until Winter '15 release, even access to Salesforce1 is not success, because user is not in approve list, but login history Status for that login is still captured as Success.

Reference: Editing a Connected App

Sunday, September 21, 2014

Best Practice Importing Data to Salesforce

Assume you already know how to load data Salesforce. In this blog, we'll use Data Loader as tool to import to Account records.

1. Data Clean up
Before loading data to Salesforce, data steward need to prepare the data to make sure data is:
  • Clean & no duplication
  • Accurate & Reliable
Bad data will cause: 
  • Decrease user adoption
  • Unusable report
  • Untrustworthy data
  • Reduce Productivity
  • Maintenance nightmare
It is suggest to clean the data before load to the system, take some efforts to get it clean and accurate, it will cost you more to clean the data if already loaded into system.

2. What to Clean
  • Delete duplicate records
  • Correct spelling and punctuations error
  • Naming convention
  • Make sure all required field is populated

3. Prepare Your Data
  • Make sure all fields to follow naming convention, example: for country, use SG instead of Singapore or SGP. Same for the phone country code and area code
  • Change row header match to field name, this will save you time and confirm it is the right mapping
  • Set correct record ownership, add OwnerId column, make sure all record have the right OwnerId, you may need to use VLOOKUP() function if using Ms Excel to prepare data
  • Split the data, if your Account have point to another Account, example: Parent Account, load account without Parent Account first, so you can get the Account Id 

4. Prepare Salesforce
  • Check all unique values from source data map to Picklist field in Salesforce, make sure they are all exist in Picklist values, unless it is no longer use in the future
  • It is good to store unique Id from the source data (if any), this will help you to confirm data is loaded correctly and your user may need this on transition period
  • Check data visibility setting: Roles, Profiles, Sharing Rules

5. Load Data
  • Test batch of 5 records only & verify it in a Sandbox instance
  • Load the rest of records (exclude 5 records loaded in test batch)
  • Optional: deactivate validation rule and workflow rule, this is depend on the need, example: you do not want workflow to trigger 1000 email alerts to Opportunity owner.
  • If everything looking good in Sandbox, repeat the steps to Production

6. Make Data Clean and Valid
  • Validation Rules
  • Picklist, Multi-Picklist, Lookup fields
  • Workflow Rules
  • Formula Fields
  • Record Type
  • Page Layout with Required & Read-Only field
  • Field-Level Security

    Saturday, September 20, 2014

    How to modify Recent items in Salesforce1 ?

    If you aware in Salesforce1 mobile app (as of version 6.0.2), recent items will show the record name and one more field.

    For example Contact, as in screenshot above in red box display Contact name and Account name as the second line. The blue box is some of the list views available for the user.

    If you need to show other field in second line, in this example is Account name to Title, how to modify it?

    1. After you login to, go to Setup - Customize - Contacts - Search Layouts - Search Results

    2. Click Edit link

    3. Top 2 selected fields will be show in Salesforce1 mobile app

    4. Add new field selected or change the field order

    5. Refresh in Salesforce1

    1. The change in Search Result will effect to ALL users including search in Salesforce website 
    2. If you are using one/ emulator to test (example:, it will just show first line, which is record name
    3. If you are using Google extension Salesforce1 Demo to show particular record, it will just show first line only, so the best still to test it in the real mobile app.

    Thursday, September 18, 2014

    Salesforce: Report Drill Down and more ...

    For many Salesforce admin using report for their daily work, sometimes we just ignore items in the report, but it is very useful to help our work.

    Drill Down
    The Drill Down picklist and button allow users to report and filter Reports on the fly right from the Run Report page without clicking the Customize button.

    If you aware, when running a Matrix or Summary report, there will be checkbox for each group.

    At the bottom of the report, there is drill down picklist and button.

    Select checkbox (for this example: Opportunity Owner) then select a value to drill down (example: Industry from Account object) and click Drill Down button. It will run the report with filtered by the Opportunity Owner and group by Industry.

    If you save the report, the filter and group will become permanently save.

    Report Option
    For Matrix report, you will find 2 "Summarize information by:" at the report option. The left one would be for row group and the right one for column group. You can change this value on the fly without customize the report.

    While for Summary report only have 1 "Summarize information by:" for the first grouping.

    Additional Option
    On top of Show and Time Frame, for some standard object, such as Opportunity, you will find Opportunity Status and Probability option.

    While for Case, we will have Units option.

    ReferenceThe Report Run Page

    Wednesday, September 17, 2014

    Salesforce: Send Email Alert for Case Comments

    Use Case: a team of user (case creator, case creator manager, case owner) need to get email alert when a case comment added to case.

    For those who not aware, we can add most recent comment added to the Case in email template
    using merge field {!Case.Last_Case_Comment}

    Using out-of-the-box feature
    Workflow have to trigger from Case Comment object, not from Case object. This mean, email alert also should trigger from Case Comment, not from Case.

    1st issue, when user add comment and not marked it as Public, Most Recent Public Case Comment is previous Comment added and mark as public, so that comment will be deliver to user email, which is not correct. We can fix this by adding IsPublished = True into the workflow Rule Criteria, so user will not get email if it is not marked as Public. This is NOT FIT with the needs.

    2nd issue, as we use Case Comment as the object in Email Alert, we cannot deliver the email to specific recipients, that information only available in Case level. This is Issue.

    Side note: Case comments marked Public will be display in Customer Portal, Self-Service Portal, Chatter Answers, Salesforce to Salesforce. Otherwise, they don't display to those channels.

    Here what we did as the workaround:

    1. Create a Long Text Area field in Case to store 'Most Recent Public Case Comment' added

    2. Create a workflow in Case Comment with Rule Criteria = True; and Evaluate the rule
    when a record is: created

    3. Create Field Update in Case Comment as action for workflow (step 2), update custom 'Most Recent Public Case Comment' in Case from CommentBody (cross object workflow). This will always bring most recent case comment, regardless it is Public or not.

    4. Create another workflow in Case to check if custom {!Case.Last_Case_Comment} is changed - ISCHANGED( Most_Recent_Case_Comment__c )

    5. Create Email Alert in Case for Workflow (step 4)
    Instead of using standard field {!Case.Last_Case_Comment} in the email template, you need to use the custom field created above (step 1).

    Creating and Editing Case Comments on Case Detail Pages

    Monday, September 15, 2014

    Salesforce: Enhanced Folder Sharing for Reports and Dashboards

    Enhanced Folder Sharing for Reports and Dashboards introduce on Summer '13 release, organization created after the Summer ’13 release will have this feature turn on default. But, if your organization existed before the Summer ’13 release, follow these steps to make folder sharing available to your users.

    Enhanced Folder Sharing grants fine-grained access to reports and dashboard folders and offers the following benefits:
        Makes sharing concepts more consistent with User,Role or Group Sharing
        Allows sharing with individual users
        Fine grained access level for each folder share (View, Edit, Manage)
        Symmetric set of profile permissions for both reports and dashboards.

    Enhanced Folder Sharing offers 3 access levels for Report and dashboards folders
        View a folder in the folder tree
        View all contents
        Run Report, Refresh Dashboard

        Everything from Viewer access plus…
        Edit all contents of a folder
        Add contents to folder
        Delete contents from folder

        Everything from Editor access plus…
        Edit folder name
        Edit/delete/remove shares

    Enhanced folder sharing offers 5 symmetric profile permissions for reports and dashboards:
        Manage Reports in Public Folders, Manage Dashboards in Public Folders
        View Reports in Public Folders, View Dashboards in Public Folders
        Create Report Folders, Create Dashboard Folders
        Edit My Reports, Edit My Dashboards
        Create and Customize Reports, Create and Customize Dashboards

    For more detail of each permissions, please refer to User Permissions for Sharing Reports and Dashboards

    For org created before Summer '13, when you enable Folder Sharing:
    • All users in the organization by default get Viewer access to report and dashboard folders that are shared with them.
    • The enhanced folder sharing does not have any impact on My Personal Custom Reports and My Personal Dashboards.
    • For the reports in Unfiled Public Reports, user will be able to create new reports and edit any reports that they created.
    • User will be able to edit any reports that user created.
    • User will only be able to edit other people’s reports if they have Editor or Manager access to the folder.

    If you had this permission in ‘old’ sharing
    You will get this permission in enhanced folder sharing
    Manage Public Reports AND View All Data
    Manage Reports In Public Folders
    View All Data
    View Reports In Public Folders AND View Dashboards In Public Folders
    Manage Public Reports
    Create Report Folder AND Edit My Reports
    Create and Customize Reports
    Create and Customize Reports
    Manage Dashboards AND View All Data
    Manage Dashboards In Public Folders AND Create Dashboard Folders
    Manage Dashboards
    Edit My Dashboards AND Create and Customize Dashboards

    • If you see mapping above, Manage Public Reports is translate into Create Report Folder AND Edit My Reports, so Edit My Reports permission is not so simple just to edit report you created, but it will allowed user to edit any reports in any folder user have access as Viewer.
    • All user able to create and Save or Save As report into Unfiled Public Reports
    • User able to edit report created by that user, even user only have Viewer access to the report.


    Saturday, September 13, 2014

    So, it's 10 Years ... !

    What is this celebration??? Today mark my journey with Salesforce technology for 10 YEARS !!!

    First of all, I would like to give my sincere thanks to my-ex employer Sqware Peg for giving me a chance to taste the beauty, simplicity and powerful of technology 10 years ago.

    Flashback to Sep 2004, I got an interview appointment at 10 AM, since I reach the place too early, walking down to Balmoral Beach at Mosman suburb in New South Wales - Australia landed me as a MVP today.

    Being part of MVP community is a big milestone on my Salesforce journey, it's an honour, big thanks to Salesforce community. This would be not a blog of my journey with Salesforce, it has been written here.

    A song for dedicated for a ten years at Grooveshark