Salesforce Lightning Connector (External Data Source / External Objects )

What is it?

  • In short: This is a new SFDC feature to retrieve and show data in SFDC without save it in the platform. 
  • External Data Source: Connection to external service to retrieve data on the fly and show it in SFDC. It could be OData 2,0 or URL Rest.
  • External Object: New type of Custom object which works as a wrapper  to expose external data.
  • Full detail in the official doc or a more lazy introduction on this video

When use it?

  • When you have to integrate a service that support OData 2.0.
  • When you are planning just ReadOnly integration.
  • When you need that data in SFDC just to be rendered and not to be calculated (what I mean is to use it in a workflow process). This is partially true depending on your intentions when accessing this data thought APEX.

How to use it?

  • Coming soon…..

Important to know

  • Data is NEVER stored in SFDC
  • External Object as an API Name like OBJECTNAME__x
  • External Object are exposed to SOQL and Apex (Wow! Yeah!!)
  • Also Views, related lists (thought External Lookup Relationship ) PageLayouts and Salesforce1
  • Global Search is supported
  • It is always possible to add a proxy service to translate any source to OData. Jitterbit and other services support it.
  • High Data Volume checkbox bypassed most of limits.
  • The authentication could be: Anonymous, Per User o Unique. Oauth 2.0 or Password.


  • Take in mind that this feature will require a special licence.
  • External Objects are not available for: reporting or workflows.
  • External Objects are READ-ONLY (I hope this would change soon since OData is Full CRUD supported).
  • Performance could be affected by the external load. Latency would be poor in some cases.
  • There are a limit of queries to be executed by hour.
  • More details in the official doc




Salesforce1 Tip: How to set different Visualfore page for Salesforce 1 and desktop UI


If you have a basic knowledge about mobile UX, you would know that it is quite important to improve the functionality for mobile in order to improve the performance, visualisation and other device implications.
Having said that, our first approach as Salesforce developers is to minify the amount of fields, related lists and also some specific functionality in the standard page layout.
There are two ways to address that:
A) One responsive page
B) Two specific pages
In the second case Salesforce does not allow you to set an specify Visualforce page for each platform frontend: Salesforce1(mobile) or FullSite (Desktop).
However you can do the following:
  1. Set the standard action (View for instance) pointing your Desktop Visualforce page.
  2. Set to false the mobile availability checkbox in that VF page.
  3. Create the second (mobile friendly) Visualforce page. Be sure that you are using a standard controller if you consider to override Edit/View actions.
  4. Check It true for  “available for Mobile apps”
  5. Create a Publisher Action pointing your new VF page.
There you have ;)

Apex Tip: Simplest way to detect Salesforce 1

If you are working to adapt or create a Visualforce page for Salesforce 1, you would know that you need to detect what type of client application (mobile or desktop) is doing the request.

You would need that in order to avoid certain apex:tags that are not compatible with Salesforce1, to change the layout and look and feel and code some special lines like replace links by;

After some research I’ve found those nice methods to detect what type of client is requesting the page

Client side (Javascript):


Server-side (Apex):


Apex Tip: get relation field value on Dynamic SOQL

I’m used to work on dynamic Apex/SQOL. I think that is always a better use this good feature of Salesforce during the development step in order to reuse the code to many SObjects as possible.

You have to understand in deep the SObject class in Apex to maximise this technique. Once you work with SObject instead of the Object (Account for instance). You are able to reuse your method/code.

The basic is quite simple, you have an SObject and you can write a field value using o.put(‘fieldName’,’value’), and read a field value using o.get(‘fieldName’).

So, you can use Database.query() method in order to get a SObject list and apply your dynamic method.

However, I’ve faced a common issue when I tried to access to a field value which came from relation field.

For example if you try to get the values from this query:

You would get this error:

My solution was to implement a recursive helper method:


Happy code ;)

Apex Tip: How to remove the action column on standard related List

Many customers ask to remove the actions (Edit, Del) from related list and the natural way to solve that is by removing Edit and Del permission on the profile.

However sometimes you need that the user have those permissions. For instance, when the user trigger a web service that update the record.

So, here the magic, using a simple line of jQuery:

Where lContacts is the ID of the related list.

Of course this need to add javascript to the page and hence it’s only possible to be used on visualforce.

Enjoy :)

Apex Tip: How to keep values during Batch iterations and get the total amount of records processed on final

As you know the Apex Batch structure has 3 basic method:

  • Start : This is only executed on the first iteration before execute
  • Execute: This method runs for each scope (more info about scope here) you defined
  • Finish : this method runs after the last scope execution

Suppose now that you want to know the total amount of records processed. The natural approach to that is to have a variable and increment on each iteration, something like this:

However,  total will returns 0.  The reason of that is Apex Batch reset attributes on each iteration  :(.

The solution for that is to include the interface Database.Stateful in order to keep the variable status over the whole execution.

Finally, you’ll have something like this:


Apex Tip: How to get a RecordType Id by Name without SOQL

The usual way to get a recordTypeId in Apex is to make a query like this:

Instead of that try this line:

Just replace Account and ‘Person Account’ by your Object and Record Type Name
I’ve been notice that “Person Account” is the label description and not the developer name of the Record Type. Having said that if you work in a multi-lang org, You’ll need to make a Query.
The most efficient way to make that kind of query is to cache the result in a static variable. Like this:


Happy coding

Salesforce Certification Tip: How to get Salesforce Developer Certification (DEV-401) studying only 12 hours ?

What to study to pass the certification exam?

dev 401

There is a LOT of good resources to study in order to get the Developer Certification (aka DEV-401). Well, I my opinion if you have a good previous experience working on the platform, let’s say more than 6 months, you don’t need to study too much to pass the exam. 

Having said that, If you focus the main points to be asked during the exam I believe you could success investing only 12 hours of study.

Those next resources were key for me:
  1. Study Guide: It is quite important to understand the topics than will be part of the exam. (30m)
  2. Force Platform Fundamentals: This is the main resource. The exam is based mostly in questions formed with samples from this book. This book explains the main features of Platform guiding over an use case called “Universal Recruitment”. Here I’ll review every non-coding developer feature like: Custom Objects, Relations, Fields, Page layouts, Security, Roles, Profiles, Applications, Views, etc, etc.  If those concepts are not new for you, you will complete it in less than 8h.
  3. Summary: There is plenty of good summaries but this is awesome. Simple, short and extend enough. This excellent post will give you a clear idea of the main limits and amounts that is good to remember. Besides the precise components definitions.
  4. Dumps: Last but not least, I think that is a good idea to get familiar with the exam methodology. Dumps for that are the faster way. This post has a good amount of question samples (they are real, old but real questions). However, take those questions as a practise over the methodology and not over the content of them because many of the answers are wrong. (1.5h)

Extra Resource

If you have time available to keep studying I found the complete podcast of lessons of DEV-401. Those videos are a slower but deeper way to know 95% of the topics that will be asked during the exam. (**20h)

Summing up

As I said, if you have previous experience in and a good technical background from my point of view you can pass the Developer Certification exam just studying well those resources.
Good luck!

Apex Tip: Create a Knowledge Base Article from Apex


If you worked with Salesforce Knowledge Base Articles in Apex, I would know that so many objects and restrictions that make that feature really difficult to rich a deep customization. 

As you can read in the official Doc you have to handle many tables related to Articles:
  • Article Type__DataCategorySelection Object A data category selection represents a data category that classifies an article.
  • Article Type__ka Object Gives access to an article from a specific article type independent of its version. This object is read–only and can’t be used in a SOQL clause or in a WITH DATA CATEGORY DataCategorySpec SOSL clause. For more information, see KnowledgeArticle.
  • Article Type__kav Object Gives access to all articles from a specific article type depending on their version. This object gives access to the fields available in KnowledgeArticleVersion. For more information, see KnowledgeArticleVersion.
  • Article Type__Feed Object Represents a single feed item in the feed displayed on the detail page for an article.
  • Article Type__ViewStat Object Provides statistics on the number of views for an article from a specific article type. For more information, see KnowledgeArticleViewStat.
  • Article Type__VoteStat Object Provides the weighted rating for an article from a specific article type on a scale of 1 to 5. For more information, see KnowledgeArticleVoteStat.
  • CaseArticle Object Represents the association between a Case and a KnowledgeArticle.
  • FeedComment Object Represents a comment added to a feed by a user.
  • FeedItem Object FeedItem represents an entry in the feed, such as changes in a record feed, including text posts, link posts, and content posts.
  • KnowledgeArticle Object Gives access to an article independent of its version. This object is read–only and can’t be used in a SOQL clause or in a WITH DATA CATEGORY DataCategorySpec SOSL clause.
  • KnowledgeArticleVersion Object Provides a global view of standard article fields across all article types depending on their version.
  • KnowledgeArticleViewStat Object Provides statistics on the number of views for the specified article across all article types.
  • KnowledgeArticleVoteStat Object Provides the weighted rating for the specified article on a scale of 1 to 5 across all article types.
  • NewsFeed Object Represents a single feed item on a user’s home tab. A Chatter feed shows recent changes to records that the user is following.
  • UserProfileFeed Object Represents a user profile feed, which tracks all actions by a user on records that can be tracked in a feed. This feed is displayed on the user profile page.
This week I had to create a REST web service to expose some FAQ articles to an external web site. That is not a big deal because you only have to query the ArticleType__kav object. The only tricky part there is to include the Language and PublishStatus in the Where clause.
Let me show you an example, if the ArticleType is FAQ, the query should be something like:

Create an Article from Apex.

After create the web service I had to create the Test Class (I really create it before ;)) I faced the problem to create the article from Apex.
After spend some time googling what table should I insert the article and what order I figured out that it is really easy. I only needed insert the article in FAQ__kav and SFDC trigger the insertion of the rest related records.
So, this is the TestHelper I made to create an Article:
More about the publishing service here.
Enjoy :)