Building great Salesforces applications for Appexchange in Axy7.com

Hi Community!

It has been a while since the last time I posted something on this blog.

My career has changed from Dev to Architect to Manager to Director and now as VP of Development in a great company.

But also I’m leading my own project in Axy7.com creating really good Salesforce apps for appexchange  such as:

  • Axy OKR:  A 100% Salesforce native app for OKR and Goal setting management to ensure Employee performance following the best practices on OKR.
  • Axy Validator: A pretty simple application to ensure Data quality by performing complex Data validations such as IBAN, VAT, Social Security number and 50+.  Within Salesforce just by setting up the simplest configuration ever.

Check it out on the Test Drive and give it a try :)

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.

Limitations

  • 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

 

Enjoy

Martín

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

Why

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).
How
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 sforce.one.navigateToSObject(objectId);

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
UPDATE:
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 Force.com 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.
    (2h)
  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 force.com and a good technical background from my point of view you can pass the Developer Certification exam just studying well those resources.
Good luck!