Salesforce Page Layout

In SalesforcePage Layouts allow for customization of UI pages for users in your organization. And often times throughout, you have pages of objects that might contain items that are not used by many users. Today, I'm going to explain how you can customize a Salesforce page layout with the fields, related lists, and custom links that suit your organization's use.

In the example below, I'll change the layout of the page Contracts. Note that you can "Edit" the current page layout of that object, but it's best to create a new Contract Page Layout and then assign it the default one.

  • To get started, go to Your NameSetupCustomizeContractPage Layout> Click on New.

  • Fill in the appropriate information and click "Save".

  • Next, drag and drop the fields, buttons, and related lists you want on the Contract Page Layout.

  • Then, click "Save".

Assigning Page Layouts

Now that you've created the page layout, you can assign it to the appropriate user Profiles in your Salesforce org.

  • Go back to the "Contract Page Layout" and click "Page Layout Assignment".

  • Pick the profile and assign the appropriate Page Layout. Then, click "Save".


Introducing Salesforce Identity

In the past organizations were able to manage their employee's access to applications and servers as a security precaution through Active Directory. But now with the cloud-based technologies, like, companies are finding it nearly impossible to manage users' access behind a firewall. Good news! Salesforce announced this week that Salesforce Identity is now open to the public: a tool that helps Salesforce admins manage user identities both in the Salesforce eco-system and in third party apps, including mobile apps. This means that a Salesforce Admin is able to set user access to apps like Evernote, Dropbox, and Sugar CRM. Salesforce Identity was first debuted at Dreamforce 2012 and had been a beta feature since.

"It's not a as straightforward as a beta because we've opened up a series of platform services that we already use for all of our customers...with Mobile Identity, for example, we've used that to deliver our own mobile applications, and we're extending that now to any application that wants to plug into our app ecosystem." Said Salesforce VP of Product Management, Chuck Mortimer.

One of the things Salesforce Identity can do is extend user privileges from Microsoft Active Directory to Salesforce users. Salesforce admins will basically be able to manage and control users' rights and access to third party apps and those within the Salesforce ecosystem all under a single console, effectively giving a single-sign-on to users in their organization.

Salesforce Identity is rumored to be free for Enterprise and Unlimited Salesforce editions. It will cost an additional $1 per user, per month, if you want to control both identity access on for cloud apps and otherwise, like Microsoft Active Directory.



Support for Testing Http Callouts

With Winter 13', Salesforce made a giant leap forward for developers who integrate and exchange information with external systems using Http Callouts. When I talk to many developers, unit tests are an after thought and a sore subject. Thankfully and I feel for good reasons that mentality is starting to shift and developers (including myself understand the true benefits. 

Let's step back for a second and look at the most common feedback I both get and see when I talk to people about unit tests. All of these are actual statements.


  • Who has time to write unit tests when we barely have time to come up with the solution
  • I'm a developer, not a tester
  • Structing my code to be unit tested takes too much time


Now that we've heard some of the excuses and objections let's look at some of the benefits


  • Tests end up being good documentation. Typically boilerplate documenation has no real value. When coders want to know how something works they look for examples and unit tests provide many.
  • Forces you to stop and think - too often we plow through and then get a critical juncture and realize that what we've done doesn't quite line up with the end result we needed. With unit tests, you can you can write out a test for the end result you need and you'll very quickly know when you get there
    • On top of this, when we stop and think we start to get creative. For example if you you expect and Integer from a method but instead get null, you quickly realize you need to handle a situation like that. i.e. handle unexpected outcomes.
  • Tests end up protecting us from the next programmer down the line. While many tend to work alone or prefer it, there is going to be a day when someone decides to change something and they just start clipping wires. The problem is that if no tests are in place you don't know the problems until they are too late. Tests are your alarm system for tampering (even when intentions are good).
  • Tests get you out of the compile run, compile run, compile run mentality when you just run and tweak until it finally works. When you do this, in the back of your mind, you know you probably didn't try everything. By adding unit tests you can very quickly simulate the bad, good users and how the code is going to react.



Okay, now that we've gotten ourselves fired up about Unit Testing we can take advatage of the changes that were made as part of Winter 13'. Before Winter 13' if your code made and outbound call (a callout) it was difficult to run unit tests against that code. Salesforce now has native support for handling callouts made in a test context. This allows you to get an artificial response that will not only increase your test coverage but it is going to simplify testing. 

A new Test.setMock method has been added. At runtime, this lets Apex know to handle the callout and generate a mock response. 

You've got two ways to Test HTTP Callsouts:


  • By implementing the HttpCalloutMock interface
  • By using Static Resources with StaticResourceCalloutMock or MultiStaticResourceCalloutMock




  1. The class that implements the HttpCalloutMock interface can be global or public
  2. By annotating the class with @isTest you'll exclude if from the callout limit of 3MB








Salesforce Tip: Simple Ways to Find Record-Type ID

In Salesforce, "Record Types" are a way to arrange and classify data in an object. An example of how Record Types can be particularly helpful is when you want to assign different sets of data to different groups of sales teams.

Whenever you're working to customize or change something in Salesforce and need to reference Record Types, you must have the appropriate Record-Type ID. There are two ways to find them:

  • Go to the Record Type (Setup> Customize> (object)> Record Types). Click on the record type. Find the Record Type ID in the URL between id= and &type.

Alternatively, you can create a custom/formula field with the value Record-Type ID

  • Go to Your Name> (appropriate object) Customize> Fields> under custom fields, 
  • Click "New". 
  • Make sure you pick Formula as the type and then Formula Text and click Next. 
  • You can label the field "Record Type".
  • Finally, enter "RecordTypeid" under Advanced Formula tab.
  • Don't forget to hit "Save".

Bulk Update Records in Salesforce

Often times in Salesforce, you need to update data on a mass scale. And there are many ways to do that- perhaps the most efficient way to mass update records is DataLoader. Alternatively, you can choose to Mass Edit/Update data directly on interface. Today, I'm going to introduce a simple and intuitive way to Mass Update/Edit from List view in Salesforce.

This feature in Salesforce comes as an app that you can install from the AppExchange, part of the Salesforce Labs: a series of Free Salesforce apps made by Salesforce's employees and developers. To get started, find the "Mass Update and Mass Edit From List View" app on the AppExchange and follow instructions to install and deploy it.


Enable Buttons in Search Layout:

With this app, you're able to mass update records of virtually any object. But first, you have to enable it in the object Search Layout. For this tutorial, I'll be using Leads as my object. Go to: Setup> App Setup> Customize> Leads> Search Layouts. Click "Edit" next to "Leads List View". Scroll down under Custom Buttons, and add the two buttons: "Mass Edit" and "Mass Update". Don't forget to click Save.


Mass Update Your Records with a Few Clicks:

After you've enabled the buttons in Leads, you can see them right in the Search Layout of Leads. You have two ways mass changing data in your records:

  • Mass Edit: this button allows you to change values of fields already displayed in the list view: select the records you want to mass edit, and click "Mass Edit".


Fill in the new values and hit Save.



  • Alternatively, you can Mass Update your records: this allows you to change the value of any fields of the object. Select the records you want to update and click "Mass Update". You'll be walked through a quick wizard:



Confirm the records you want to update, then click "Next":



Then, pick the field you want to change, then hit "Next"


Enter the new value of the field and click "Next" then confirm the changes by clicking "Update" then "Done".



This app works great for mass updating a relatively large number of records. It is free and can be used in any object in Salesforce.


Introducing Salesforce Connect Offline

Up until recently, using offline was unheard of. Fortunately, Salesforce recently released a new piece of software that allows you to do just that-- using Salesforce totally unplugged! Today, I'll be giving a brief introduction to Connect Offline: a client application that allows you to do your work in Salesforce offline.


The way Connect Offline works is by allowing you to perform tasks and changes to your Salesforce offline, then when connected online, it synchronizes the Connect Offline database with Salesforce's and pushes all changes made over to Salesforce.

What makes Connect Offline particularly convenient is that it lets you perform all typical Salesforce tasks smoothly. Here's a list of what you can do in Salesforce when offline:


The subset of data you can access in Salesforce while offline is called a briefcase. Admins can configure the parameters of a briefcase: thereby determining what data is accessible in a briefcase. For example, if you want to create a Connect Offline briefcase specifically for salespeople, then you would configure the briefcase to only include Leads and Accounts.


Connect Offline comes with support for mobile and various browsers and operating systems. It is also available for free for Enterprise, Unlimited, and Developer Editions. Also available for additional cost to Professional Edition. It will be interesting to see how this new software might change habits of how organizations work with Salesforce and how it might increase productivity among users.


Top 5 New Features in Salesforce Winter '14

It's that time again, Salesforce is about to introduce its next iteration: Salesforce Winter '14. The new release is said to be packed with valuable improvements that should enhance the overall experience as well as improvements under the hood. Today, I'm going to highlight the  5 most noteworthy features of Salesforce Winter '14:

Introducing Salesforce Performance Edition

Beginning in November of this year, Salesforce will be rolling out a brand new edition named Performance Edition. The edition will include all functionality of the Unlimited Edition on top of, which provides targeted customer data as well as

Salesforce Console for Sales

Salesforce Console for Sales basically combines the features of Agent Console and the Service Cloud Console together. This feature will prove very valuable, especially to salespeople. Instead of having to abandon the current page and go to the previous one, salespeople will be able to keep view of their critical fields and related lists and opportunities in a side panel. Check out the screenshot below of the new Salesforce Console for Sales.

Deployment Monitoring

The Monitor Deployments page will get new improvements. When deploying through the Migration Tool, you will now get more detailed information on the status of the deployment:

  • In Progress: this basically means that the deployment has started but is not finished yet.
  • Pending: This means that the deployment hasn't yet started but is queing to start.
  • Succeeded–All: All components of deployments and tests have succeeded.
  • Succeeded (partially): This means that the deployment went ahead with some errors either to some components or ones related to tests.
  • Cancel Requested: The status means that the deployment is starting to get cancelled.
  • Cancelled: This status means that the deployment has been fully cancelled.
  • Failed: This means that the deployment has failed and subsequently no changes were made to the org either because some files/components were missing or as a result of errors in tests.

Embedded Analytics

With Winter '14, you'll be able to embed performance analytics unto a page layout. This feature, if used properly, can be very helpful especially to organizations who rely on reports and performance, trends, status info. Here's a picture of it below:

Search for Configurations in "Setup"

This is probably my favorite feature of all. With Salesforce Winter '14 you'll be able to find Setup Menu Items and Setup Configuration Records by simply searching for them under Setup. Here are some of the new items you can search and find under Setup:

  • Setup Pages
  • Custom Profiles
  • Permission Sets
  • Public Groups
  • Roles
  • Users


These are only some of the new features that will be rolling out with Salesforce Winter '14. For more info on the new release of Salesforce, check out this page:


Salesforce: Re-enter Passwords to Verify Users' Login

There are many areas in Salesforce you can work on to improve security. In fact, the latest was introduced earlier this year, a two-step authentication system that uses SMS to confirm the identify of users logging into Salesforce.

But If you're developing an app for Salesforce, especially an app that deals with critical data, it is important to make sure that the users logged in are, in fact, who they say they are.

Today I'm going to show you how you can add an extra layer of protection by prompting the users to re-enter their Salesforce passwords after they've logged in. This way you can verify that it's only designated users who have access to your (critical) data.


The way this verification process will work is that after a user logs in, an API callout is made to prompt the user to re-enter the password.


Below is the two parts of code. The first is a VisualForce page that prompts the user to enter their password. The second block of code is the Controller.



<apex:page controller="VerifyPassword">
    <apex:sectionHeader title="Verify Password"/>
    <apex:pageMessages />
    <apex:form >
        <apex:pageBlock title="" mode="view">
            <apex:pageBlockButtons >
                <apex:commandButton value="Verify" action="{!doVerify}"/>
            <apex:pageBlockSection title="My Content Section" columns="1">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Username" for="username"/>
                    <apex:outputText value="{!username}" id="username"/>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Password" for="password"/>
                    <apex:inputSecret value="{!password}" id="password"/>




class VerifyPassword {
    public final String LOGIN_DOMAIN = 'test'; //other options: test, prerellogin.pre
    public String username {get{ return UserInfo.getUsername(); }}
    public transient String password {get;set;}
    public PageReference doVerify(){
        HttpRequest request = new HttpRequest();
        request.setEndpoint('https://' + LOGIN_DOMAIN + '');
        request.setHeader('Content-Type', 'text/xml;charset=UTF-8');
        request.setHeader('SOAPAction', '""');
        //basically if there is a loginResponse element, then login succeeded; else there
        //  would be soap fault element after body
        final Boolean verified = (new Http()).send(request).getBodyDocument().getRootElement()
          .getChildElement('loginResponse','') != null;
        if(verified) ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.CONFIRM, 'Correct password!'));
        else         ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.ERROR, 'Incorrect password!'));
        return null;
    public static String buildSoapLogin(String username, String password){
        XmlStreamWriter w = new XmlStreamWriter();
        w.writeStartElement('', 'login', '');
        w.writeNamespace('', '');
        w.writeStartElement('', 'username', '');
        w.writeStartElement('', 'password', '');
        String xmlOutput =
              '<Envelope xmlns=""><Body>'
            + w.getXmlString()
            + '</Body></Envelope>';
        return xmlOutput;





Using Salesforce to Track User's Location

In some scenarios, organizations where data collection is important, capturing the location of where the users are entering new information can be helpful. Today in this article, I'm going to give a tutorial of how you can allow Salesforce to log the users' location when, for example, a new record is saved in a sales visit. 

To do that, we're going to create a new tab (Sales Visit) that contains a Visualforce page. The Visualforce page will then capture the location of the users when they save a new record. 

First, let's create the object Sales Visit:

Go to Setup> Create> Objects> New Custom Object and put "Sales Visit" as the label of the object.

Then, we're going to create three custom fields:


  • Description: choose Text Area as data type. 
  • Longitude: Choose Number as the data type. Enter 3 as the length and 10 as the Decimal Places. After you hit save, create Latitude with the same data type, length, and decimal places. 



Second, create an Apex Class (which performs like the Sales Visit but with a slightly different behavior):

The difference of behavior for the Apex Class is that normally when you save a new record, the record's detail page is displayed. Because we don't want to overload the phone's small screen with unnecessary information, we're going to replace the record's detail page with a blank Sales Visit record instead.

Go to Setup> Develop> Apex Classes> New and then enter in the following code then hit Save:


public class visitController {

    public Sales_Visit_c visit__c();}


    public visitController() {

        visit = new Sales_Visit__c();


    public PageReference save() {

        insert visit;

        visit = new Sales_Visit__c();

        return null;




Create a Visualforce page that captures and sends the GPS coordinates of when the sales visit record is saved:

Go to Setup> Develop> Pages> New

Enter Sales Visit Form as the label and name.

Delete the markup that gets automatically created with the following code:


<apex:page controller="visitController" showHeader="false"

    sidebar="false" setup="true" standardStylesheets="false"



    <meta content="width = device-width"/>




    function updateLocation(lat,lon) {  






    function getLocation() {


        //work around required for BB

        if (window.blackberry)

            setInterval("getLocation()", 10000);

            return false;







    Sales Visit Name: <br />

    <apex:inputField value="{!}" /><br />

    Sales Visit Description: <br />

    <apex:inputField value="{!visit.Description__c}" /><br />

    Longitude: <br />

    <apex:inputField value="{!visit.Longitude__c}"

        /><br />

    Latitude: <br />

    <apex:inputField value="{!visit.Latitude__c}"

        /><br />

    <button value="GPS"

        onclick="getLocation();"> Get location </button>

    <apex:commandButton action="{!save}" value="Save!" />



After that include Sales Visit in a new Salesforce tab:

to do so, go to Setup> Create> Tabs> New. Then, select Sales_Visit as the Visualforce Page. Enter Sales Visit as the tab label. Then, make sure to mark "Mobile Ready" to enable this tab in mobile mode.

And now, whenever a new record is saved in Sales Visit, the location of the user is captured along with it. Note that you must set all users’ phones to allow recording of the GPS location for the browser.