Salesforce User Interface API

With new Salesforce UI API we can get the orgs data and metadata in a single response returned form an Api call. Even Salesforce uses the same UI API to build their Lightning Experience and Salesforce for Android, iOS, and mobile web.

While making calls and getting the data, salesforce does take care of checking the field-level security settings, sharing setting, and perms. We don't have to worry about making the SOQL queries to get record data, getting object metadata and themes info, getting layout info, all this heavy lifting work will be taken care by Salesforce. Best part is that every response is returned in a formatted JSON!

UI API Endpoints are divided into 3 levels namely
1. Records Endpoint
2. Actions Endpoint
3. Favorites Endpoint
For Authentication, User Interface API uses OAuth 2.0 just like all other Salesforce REST APIs does

Reference Links:
1. User Interface API Developer Guide
2. Salesforce Blog by Raja Rao DVSalesforce UI API helps with below features:

1. …

SFDX - Create and Deploy Project to Dev Hub using VS Code

In this blog post we are going to create a sample project in Scratch Org and deploy it to Dev Hub using VisualStudio Code using SFDX commands
Create DevHub Account: In order to create a Scratch Org we need to have a DevHub Account which can be created using this Link. This DevHub is a free account and is valid only for 30 days to use! Create Scratch Org: Once we have our DevHub Account created and now we can go ahead and create our Scratch Org using below commands Also make sure you have CLI installed for Windows/Mac using Install the Salesforce CLI steps

Now lets go ahead and authorize DevHub using "sfdx force:auth:web:login -d -a MyDevHub" from terminal and this will prompt you to allow access screen and once authentication is successful you will see a message saying 'You may now close the browser' like below

Now that we have authenticated our DevHub, let's check logging into it using alias name 'MyDevHub' which we gave in above step. From te…

Displaying Toast Message from Modal in Lighting Components

With traditional Visualforce development we use apex:pageMessage to display custom messages to the User. And now with Lightning Components development we can use force:showToast to display custom messages!

Here we are going to display our Toast Messages from a Modal and expose it through a Lightning Component Tab. Below we are going to create our custom Lightning Component and Lightning Component custom Tab.

LightningToastMsg.cmp: This is our component code
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,force:lightningQuickActionWithoutHeader,force:hasRecordId" access="global"> <!--Load LDS from static resource--> <ltng:require styles="/resource/SLDS/assets/styles/salesforce-lightning-design-system.css"/> <!--Define Modal--> <div class="demo-only" style="height: 800px;"> <section role="dialog" tabindex="-1" aria-l…

Using Aura:Set with Lightning Components Extension

When we think about Object Oriented Concepts, Inheritance is one thing where we can extract functionality from Super Class and in Lightning Components development aura:set serves with similar feature where we can assign values for the attributes of a Super Component from a Sub Component which extends a Super Component.
Resource Link: Lightning Components Developer Guide

Below is a simple implementation of having two components and using aura:set we will populate attributes of a base component using another component which will extend our base component.

Component 1: This will be our base component which will display records Name and Id which are passed from Component 2 using Aura:Set

AuraSet1.cmp <!--AuraSet1--> <aura:component extensible="true" > <!--Load LDS from static resource--> <ltng:require styles="/resource/SLDS/assets/styles/salesforce-lightning-design-system.css"/> <aura:attribute name="rcd" t…

Salesforce Lightning Container Overview

Earlier with Visualforce we have a way of exposing an external App using "iframe". Now with Lightning Component Development we have a similar functionality available with Lightning Container which hosts all external App content in an "iframe" which makes Lighting Container a powerful way of rendering external apps within our Lightning Components. In order to use external App within Lighting Container, we will just need to upload our App to a Static Resource and reference it under Lightning Container.

Lightning Container in action: Lets go ahead and use a simple JavaScript App (Source Link) and save it under Static Resource and see how it is rendered when used in Lightning Container.

Step 1: Copy paste below Code in a new text editor and save it as ".html" file.
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Countries CRUD</title> <style> input[type='submit'…

Lightning Data Service - Salesforce new Apex alternative - Part 2

We have looked on some basic code for Loading and Updating a record using Lightning Design System in my last blog post. Here we are going to work on creating and deleting a record in Lightning Component using Lightning Design System.1. Creating a Record: For creating a new record using LDS we declare force:recordData without assigning a recordId unlike what we use to do with Load and Update record. And then we load a record template by calling the getNewRecord function on force:recordData and finally we handle saving data using saveRecord in our 'handleSaveRecord' function.

Lightning Components Developer guide already have some basic code on creating a Contact record (Reference Link). We are going to extend that code a bit to first create a new Account record and then create a new Contact record by linking it to the Account that we created all in one single shot.

Below we are going to create a new Lighting Component from Developer Console by navigating to File-->New--…

Lightning Data Service - Salesforce new Apex alternative - Part 1

Lightning Data Service which is currently in Beta are Salesforce new alternative of using Apex in Lightning Components. Basically we can perform View, Save, Update, and Delete of any sObject record in Lightning Components without using Apex Code!

Lightning Data Service also respect org sharing rules and FLS settings, records that are loaded in LDS are cached and shared across components and components accessing same record see significant performance change, since the record is loaded only once and it doesn't matter how many components are using it. When one component updates a record, the other component using it are notified and refresh it automatically.

Resource Link: Lightning Data ServiceLets have a look at how Lightning Data Service works in Lightning Components.1. Loading a Record: This is the foremost simplest that we can do using LDS. Here force:recordData tag is what we use in our component and that is the key for our component to load record. Every force:recordData …