Migrating existing projects to Salesforce DX

If your source code is currently in a Developer Edition org or Sandbox org, and you want to move to Salesforce DX, follow the steps given in the below blog by Christophe Conraets.

Migrating Existing Projects to Salesforce DX

The blog post details the below three steps for migrating to Salesforce DX:

1. Convert your project to Salesforce DX
2. Transfer sample data
3. Put your project under version control

https://developer.salesforce.com/blogs/developer-relations/2017/07/migrating-existing-projects-salesforce-dx.html
Continue Reading →

Apex - Pass by Value and Pass by Reference

“In Apex, all primitive data type arguments, such as Integer or String, are passed into methods by value. This means that any changes to the arguments exist only within the scope of the method. When the method returns, the changes to the arguments are lost.
Non-primitive data type arguments, such as sObjects, are also passed into methods by value. This means that when the method returns, the passed-in argument still references the same object as before the method call, and can’t be changed to point to another object. However, the values of the object’s fields can be changed in the method.”


The key takeaway for non-primitive data type arguments like Lists, Maps, sObjects etc is: when these variables are passed to methods, and the sObject's fields (or List's elements) are updated in the method, the updated values are retained when the method returns. 

Read below posts for detailed explanation with code examples.

This blog post by Josh Kaplan details about passing parameters By Reference and By Value in Apex.
https://developer.salesforce.com/blogs/developer-relations/2012/05/passing-parameters-by-reference-and-by-value-in-apex.html

This works in the same way as Java, here is a post explaining pass by reference in Java. 
https://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value/7034719#7034719

Continue Reading →

Salesforce Certification: Data Architecture and Management Designer Exam

Here is a detailed blog post from Sudipta Deb on How to Prepare For and Clear Data Architecture and Management Designer Exam. This exam is one of the required certification exams on the Salesforce Technical Architect journey.

http://www.sudipta-deb.in/2018/06/how-to-prepare-for-and-clear-data.html
Continue Reading →

Advanced Concepts on Lightning Components

This TrailheaDX session by Christophe Coenraets explains concepts like how to cache data efficiently, how to build for performance, Data Binding, Lightning Data Service, Service Lightning Components etc.

Below are some of the key points discussed in the video:

1. Cache data on the client side whenever possible. Go to server only as a last resort. Consider the example of paginating through data in a lightning component. It is a bad approach to go to server to fetch the data every time Next or Previous button is clicked although a particular page data was viewed just a while ago.

The solution is using Storable Actions. Simply use action.setStorable(); to enable storing the result of the action callback in client cache. Only use setStorable in non-mutable function (functions that do not update data in the database).

The video also explains in detail about refreshAge (30 sec) and expirationAge (900 sec) and what happens when we try to retrieve the data after these times have passed.

Note: Do not use JavaScript Promises with Storable Actions.

***************************
Update: Winter'19 Release: API Version 44.0
***************************

Now you can mark the Apex method as storable (cacheable) and get rid of any setStorable() calls in JavaScript code using @AuraEnabled(cacheable=true) annotation.

2. Data Binding: Bound Expressions vs Unbound Expressions.

Bound Expressions - Two way data binding or bi-directional data binding.
{!contact.FirstName}
Unbound expressions - one-time data binding (not one-way!)
{#contact.FirstName}

Unbound expressions works well with iterations (<aura:iteration>) because we already have the object array and we are looping through the array to display the data.

Why is Bound Expressions called Two-way binding and Unbound Expressions called One-time data binding? Check the video for detailed explanation.

3. Service Lightning Components

Lightning Components that have no UI. They can be used as reusable services.
<aura:method> is used to defined the method name that a parent component can call.

4. Three types of  Events: Component Events, Application Events and Platform Events.
The video briefly explains when to use what type of event.



Continue Reading →