Day: May 11, 2018

force:recordEdit Example

In this blog, I am going to explain how to use force:recordEdit component to implement the custom edit for any object. A force:recordEdit component represents the record edit UI for the specified recordId.This component display fields in the order they appear on the corresponding page layout and record detail page. This example displays the record edit UI and a button and when button pressed saves the record.

The Example which I am using is here is simply get the record id by using force:hasRecordId interface with overriding the Edit Button on the contact.

Here is the sample code.

Code Highlights 

  • force:recordSaveSuccess event is used with onSaveSuccess after the record is successfully updated. Fired when record saving was successful.
  • e.recordSave is used to fire the save event of force:recordEdit

Go to the contact and override the edit button as shown below

Once you click on Edit record you can see now its override force:recordEdit component. 

After the successful update of the record, it will show the toast message as shown below. 


Lightning Component Canvas Example


In this blog, I am going to explain Heroku and node js canvas integration on lightning experience by using force:canvasApp .


  1. Git installed on your local machine
  2. Heroku account
  3. Heroku toolbelt installed.
  4. Node.js installed on your local machine

Creating Connected App

In order to integrate the salesforce with Heroku application, you need to create the configure the salesforce connected app.

  • Setup -> Create -> Apps -> Connected Apps-> New
  • Fill  Connected App NameAPI Name, and Contact Email
  • Check the Enable OAuth Settings in the API (Enable OAuth Settings) section
    • Callback URL: add as Later after deploying node js app to Heroku, we need to change this.
    • Selected OAuth Scopes: select the scopes you want for the NodeJS app access token to grant.  Select as ” Full Access ” for this testing app.
  • In the section, Canvas App Settings type Check Canvas
  • Canvas App URL: after deploying the apps Heroku, we are going to change this URL.
  • Access Method: Signed Request (POST)
  • Locations: choose Chatter Tab and publisher as of now. but you can select one or more based on the where you want to show this the canvas on salesforce. Now final connected App is looking as shown below.

Now you need to enable the app for the profiles or users. To do this,

  • Click on the Manage on the connected App which you created in above .click edit policies
  • In the OAuth policies select Admin approved users are pre-authorized for the Permitted Users field and save it
  • In the Profiles related list add the profiles which you wanted to grant access.

Building Your App on Node Js

Let’s set up the basic app structure. We will use Express to set up a basic Node application. Here is the below package.json file which we will use to build the node js application. Application folder structure is shown below.


use below package.json file


  • Once you have created your file structure, set up a Git repo in this directory by running from command. $ git init your command line within this directory.
  • Inside of the public > views > index.html file, add the following code


  • From the command line in the main app directory initialize your Node app by running -.npm install which will load all the node modules from the package.json

In the index.js file add the following code:

Run the following from the command line within your main app directory to push your changes to Heroku.

  1. heroku create
  2. git add .
  3. git commit -m "pushing to heroku"
  4. git push heroku master
  5. heroku open
    Open the URL which looks like

Now go to the Connected app which you created in earlier, update the callback URL and Canvas App URL with the Heroku app URL  example We have to add the environmental variable to the Heroku app with the  Consumer secret from the connected app. Run the below command to set the environmental variable

Lightning component

Here is the lightning component that will invoke the canvas app

force:canvasApp component represents a canvas app that’s embedded in your Lightning component as shown in the above code.




In this blog, I am going to show how to use the aura:iteration to renders a view of a collection of items. aura:iteration iterates over a collection of items and renders the body of the tag for each item. The Below are the different examples to show how you can use iteration.

Simple iteration

In this example, we are iterating over the array of String.

Nested Iteration

The following code nested iteration

Object iteration

The following example shows iteration over the Javascript object

Wrapper Class Iteration

The Following Example shows how to iterate   the wrapper class collections

Server Side Controller 

The following example shows how to iterate the server-side data

Iteration Index

The Following code shows how to get the index of iteration position.




Conditionally Renderings with aura:if

In this blog I am going to show how to use aura:if to conditionally instantiates and renders either the body or the components .aura:if evaluates the isTrue expression on the server and instantiates components in either its body or else attribute. Only one branch is created and rendered any time with if condition. Below is the sample example how it looks like

Simple If Conditions

The below code contains two attributes to test if attribute is the boolean type and another attribute is of type List.

Here is the simple App for testing. The first time when the component is instantiated we are setting the flag to false and array size is greater than zero.The second time we are getting the flag to true and array to empty.

 Simple If Else

In this below code just I am using one flag to test if and else conditions. You can see an output with both the condition if the flag is true or false.

Here is the simple App to invoke the component. When you set the flag as false it will display the false message as true condition and else message is coming from the else condition.

When you set the flag as true


Nested If Else

 The below code we have two attributes to show the outer and inner if conditions.
If you set both outer and inner attributes to the .it will display the data as shown below.

If Else with Iteration 

The below code shows how to Iterate over the list and display the data based on the attribute “showEven”.

If you set “showEven” to false it will display only odd numbers as shown below.

If Else with Server Side Controller 

Simple Apex code that will return false


When you invoke this component, it will display the message based value return from the server side code.