Algorithm to generate the unique id in salesforce using Apex

There might be scenarios where we as a developer needs to generate random unique ID’s to be used for external integrations in Apex.

Here is a simple method which generates the unique code everytime.

public static String getUUID()
        Blob b = Crypto.GenerateAESKey(128);
        String h = EncodingUtil.ConvertTohex(b);
        String guid = h.SubString(0,8)+ '-' + h.SubString(8,12) + '-' + h.SubString(12,16) + '-' + h.SubString(16,20) + '-' + h.substring(20);
        return guid;

Sumanth A [03/08/2019]

Steps to Enable Event Monitoring dashboards in PROD/Sandbox


I am going to produce the steps to Enable Event Monitoring dashboards in Salesforce Sandbox /Production Environment….

Pre-Requisite: >> Enable Analytics >> Setup >> Analytics >> enable Analytics (This is a major step without this you won’t see analytics studio app)

  1. Setup >> Event Monitoring >> Enable Login Forensics and Event Log File Integration with Event Monitoring Analytics App
  • Open Analytics studio app >> Click on that and a new tab will open (FYI., pop up from browser might block this so set it to allow)
  • Create >> Click on it
  • Follow the below screen steps
  • You will see steps 1 to 5 don’t change anything except the no. of days to 30
  • Name the App “Event Monitoring App”
  • The app will run and you will see the below screenshot and an email will be sent once its ready.

Hope you got all the details!

Anil B [03/03/2019]

Email Quick Action missing in Feed Tab

In this post, I am going to provide you with the steps to debug the issue: Email Quick Action missing in the feed Tab…

  1. Login to salesforce Sandbox ( or Production org
  2. Navigate to the app (ex. Service console) using app launcher
  3. Open Case page and check if the quick action is visible
  4. Follow the below steps only if quick action is not visible
  5. Setup>>Object Manager>>Case object>>Case Page Layouts>>check if the quick action is added to the case page layout
  6. Drag and Drop the quick action into the layout and click save
  7. Even now if the quick action is not visible now then please follow the below steps
  8. Setup>>Administer>>Email Administration>>Deliverability>>Set Access to Send Email (All Email Services) to All Email>>Click Save.
  9. FYI., Screenshot for reference

Anil B[03/03/2019]

Connecting Sandbox (Dev) to Visual Studio code For Developing Lightning Web Components(LWC)

Here, I am going to present you the steps to connect the Sandbox to Visual Studio Code for connecting the Lightning web Component…

First step: Install Salesforce Extensions for Visual Studio Code

screenshot for Extensions in VS Code
Lightning Web Components Extension

Login in to Sandbox and Use the below command in the Terminal

sfdx force:auth:web:login –setalias my-hub-org –instanceurl

After logging in…

  1. Use ctrl+shift+p
  2. Enter Sfdx:create Project
  3. Select the Source where you want to create Project.

To Create Lightning web Component use the Below Command in Terminal

sfdx force:lightning:component:create –type lwc -n myComponent -d force-app/main/default/lwc

AND Finally to deploy use the command below:

sfdx force:source:deploy -p force-app -u name of the Sandbox)

Also, Follow the Link below for better experience on Lightning Web Component:

-Ranjith T [02/25/2019]

Cron expression for scheduling jobs in Salesforce

In this post, I am going to share the information about Cron expression for scheduling jobs in Salesforce

Cron Expression

Cron Expression syntax :-
“Seconds Minutes Hours Day_of_month Month Day_of_week optional_year”

The following are the values for the expression:

Name Value
Seconds 0–59
Minutes 0-59
Hours 0-23
Day_of_month 1-31
Month 1-12
Day_of_week 1-7
optional_year null or 1970–2099

Cron Expression Examples

Expression Description
0 0 0 ? * * * at 12:00 AM every day
0 0 10 ? * * at 10.00 AM every day
0 0 10 * * ? at 10.00 AM every day
0 0 10 * * ? * at 10.00 AM every day
0 0 15 ? * * * at 3:00 PM every day
0 0-5 15 * * ? Every minute starting at 3:00 PM and ending at 3:05 PM, every day
0 15 17 ? * MON-FRI at 5:15 PM every Monday, Tuesday, Wednesday, Thursday and Friday
0 15 10 15 * ? at 5:15 PM on the 15th day of every month
0 15 17 ? * 6#3 at 5:15 PM on the third Friday of every month
0 0 18 ? * 6L runs the last Friday of every month at 6:00 PM.
‘0 30 * * * *’; every 30 minutes
0 0 12 * * ? at 12:00 PM every day
0 0 23 * * ? 2016 runs every day at 11:00 PM during the year 2016.
? – No Value
* – All Values
L – Last
– Chandra V [01/12/2019]

Validation Rule Requiring Lead Fields Prior to Conversion

In this post I am writing a validation rule that requires all of these fields prior to Lead conversion.

Need is a checkbox, Languages and propsepct role are picklists, Notes and SDR are text…

Below is the successful Formula that works for the above criteria:

Also, If the  Notes__c a Rich Text area field, then you need to use this:


If the above don’t work either, then check the following:
This Lead Settings should be checked in order for the Validation Rule to Fire.
Hope this information helps you!
– Chandra V [01/12/2019]



In this Post, I would like to get the most important points on the Einstein Analytics to this Blog, through which one can understand it’s significance in improving the Business.

  1. Work with a platform you can trust
  2. Save on expenses
  3. Get set up quickly
  4. Cut out the fluff
  5. Customize your solution
  6. Enjoy built-in support
  7. Integrate your data
  8. Integrate with the entire Salesforce ecosystem
  9. Easily explore customer data from every source
  10. Bring your people together
  11. Unify your goals
  12. Collaborate from the dashboard
  13. Generate presentation-worthy visuals
  14. Be a part of the conversation
  15. Put it all into context
  16. Never be out of reach
  17. See team performance
  18. Access relevant KPIs
  19. Track call-center efficiency
  20. Chart changes
  21. Become a better coach
  22. Empower your teams to analyze themselves
  23. Eliminate the holes in your campaigns
  24. See the big picture
  25. Eliminate borders
  26. Find the devil in the details
  27. Predict the future
  28. Reduce churn
  29. Focus on the right leads
  30. Evaluate your lead sources
  31. Recognize your biggest wins
  32. Optimize the customer experience
  33. Dive deeper
  34. Present the right message
  35. Be your own data analyst
  36. Take instant action
  37. Make B2B marketing your speciality
  38. Understand the brand experience
  39. Set your priorities
  40. Evaluate your accounts
  41. Connect with your agents
  42. Review your service backlog
  43. Integrate with third-party applications
  44. Go mobile
  45. Optimize your pipelines
  46. Automate your analysis efforts
  47. Enjoy the highest level of data security
  48. Push the limits
  49. Gain deeper visibility into your business
  50. Keep up the pace                                                                                                                                                                                         – Sumanth A[01/04/19]

Lightning Action Icons

A Lightning:Icon is a visual part that gives setting and updates usability. Images can be used inside the body of another part or isolated.

Below is the sample code for displaying the action icons in order:


<lightning:icon iconName="action:approval" alternativeText="Approved" />
<lightning:icon iconName="doctype:audio" alternativeText="Audio file" />
<lightning:icon iconName="standard:event" alternativeText="Event" /> <lightning:icon iconName="utility:connected_apps" alternativeText="Connected" />
<lightning:icon iconName="utility:warning" alternativeText="Warning!" variant="warning"/>
<lightning:icon iconName="utility:error" alternativeText="Error!" variant="error"/>
<lightning:icon iconName="utility:image" alternativeText="Utility image" />
<lightning:icon iconName="doctype:image" alternativeText="Doc image" /> </aura:component>

Ranjith T [12/19/2018]

Custom Data Table With Pagination And Checkbox Functionality In Salesforce Lightning

In this post I am  going to show how we can create custom lightning data table with client side JavaScript pagination buttons and row level checkbox functionality using salesforce lightning component. In this component we’ll also persist checkbox checked state on pagination.

Apex Controller : dataTableCtrl
public class dataTableCtrl{
    public static List<accountListWrapper> fetchAccountWrapper(){     
        List<accountListWrapper> lstaccountListWrapper = new List<accountListWrapper>();
        // query account records and create 'accountListWrapper' class instance for each record. 
        for(Account acc : [Select id,Name,Type,Phone
                           From Account
                           Limit 1000]){
                               // by default checkbox should be false 
                               lstaccountListWrapper.add(new accountListWrapper(false,acc));
        // return the 'lstaccountListWrapper' list 
        return lstaccountListWrapper;
    /* wrapper class */  
    public class accountListWrapper {
        @AuraEnabled public boolean isChecked {get;set;}
        @AuraEnabled public  account objAccount{get;set;}
        public accountListWrapper(boolean isChecked, account objAccount){
            this.isChecked = isChecked;
            this.objAccount = objAccount;
Lightning Component
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction"
<!-- call doInit method on component load -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<!-- aura attributes to store data/values -->
<aura:attribute name="listOfAllAccounts" type="list"/>
<aura:attribute name="PaginationList" type="list"/>
<aura:attribute name="selectedCount" type="integer" default="0"
description="selected Records Count"/>
<aura:attribute name="startPage" type="Integer" />
<aura:attribute name="endPage" type="Integer"/>
<aura:attribute name="totalRecordsCount" type="Integer"/>
<aura:attribute name="pageSize" type="Integer" default="4"
description="number of records to be display on per page"/>
<aura:attribute name="currentPage" type="integer" default="1"/>
<aura:attribute name="totalPagesCount" type="integer"/>
<aura:attribute name="bNoRecordsFound" type="boolean"/>
<aura:if isTrue="{!v.bNoRecordsFound}">
<!--display error message if there is no records available -->
<div class="slds-notify slds-notify_alert slds-theme_alert-texture slds-theme_info" role="alert">
<span class="slds-assistive-text">error</span>
<h2>No record found.</h2>
<aura:set attribute="else">
<!-- lightning:button to get selected rows data -->
<div class="slds-clearfix slds-m-around_small">
<div class="slds-clearfix">
<div class="slds-float_right">
<lightning:button variant="destructive"
label="Get Selected Records"
onclick="{! c.getSelectedRecords }"
disabled="{!v.selectedCount == 0}"/>
<!-- display total record and selected record count -->
<p class="slds-m-around_small">
<span class="slds-badge slds-badge_lightest" style="display:inline-block">
Total Records : {!v.selectedCount > 0 ? v.selectedCount + '/' : ''} {!v.totalRecordsCount} 
<!-- data table start-->
<table class="slds-table slds-table_bordered slds-table_cell-buffer">
<tr class="slds-text-title_caps">
<!--header checkbox for select all-->
<th style="width:3.25rem;" class="slds-text-align_right">
<div class="slds-form-element">
<div class="slds-form-element__control">
<label class="slds-checkbox">
<ui:inputCheckbox disabled="{!v.totalRecordsCount == 0}"
<span class="slds-checkbox_faux"></span>
<span class="slds-form-element__label"></span>
<th scope="col">
<div class="slds-truncate" title="Name">Name</div>
<th scope="col">
<div class="slds-truncate" title="Phone">Phone</div>
<th scope="col">
<div class="slds-truncate" title="Type">Type</div>
<aura:iteration items="{!v.PaginationList}" var="obj">
<th scope="row" class="slds-text-align_right" style="width:3.25rem;">
<div class="slds-form-element">
<div class="slds-form-element__control">
<label class="slds-checkbox">
<ui:inputCheckbox text="{!obj.objAccount.Id}"
<span class="slds-checkbox_faux"></span>
<span class="slds-form-element__label text"></span>
<th scope="row">
<div class="slds-truncate" title="{!obj.objAccount.Name}">
<th scope="row">
<div class="slds-truncate" title="{!obj.objAccount.Phone}">
<lightning:formattedPhone value="{!obj.objAccount.Phone}"/>
<th scope="row">
<div class="slds-truncate" title="{!obj.objAccount.Type}">
<!-- DataTable End -->
<!--  Pagination Buttons Start -->
<div class="slds-align_absolute-center">
<lightning:button label="Previous"
disabled="{!v.startPage == 0}"
<span class="slds-badge slds-badge_lightest"
style="margin-right: 10px;margin-left: 10px;">
                    Page {!v.currentPage} out of {!v.totalPagesCount}
<lightning:button label="Next"
disabled="{!(v.endPage + 1) >= v.totalRecordsCount}"
<!--  Pagination Buttons End -->
Java Script Controller
doInit: function(component, event, helper) {
helper.doInitHelper(component, event);
/* javaScript function for pagination */
navigation: function(component, event, helper) {
var sObjectList = component.get("v.listOfAllAccounts");
var end = component.get("v.endPage");
var start = component.get("v.startPage");
var pageSize = component.get("v.pageSize");
var whichBtn = event.getSource().get("");
// check if whichBtn value is 'next' then call 'next' helper method
if (whichBtn == 'next') {
component.set("v.currentPage", component.get("v.currentPage") + 1);, event, sObjectList, end, start, pageSize);
// check if whichBtn value is 'previous' then call 'previous' helper method
else if (whichBtn == 'previous') {
component.set("v.currentPage", component.get("v.currentPage") - 1);
helper.previous(component, event, sObjectList, end, start, pageSize);
selectAllCheckbox: function(component, event, helper) {
var selectedHeaderCheck = event.getSource().get("v.value");
var updatedAllRecords = [];
var updatedPaginationList = [];
var listOfAllAccounts = component.get("v.listOfAllAccounts");
var PaginationList = component.get("v.PaginationList");
// play a for loop on all records list 
for (var i = 0; i < listOfAllAccounts.length; i++) {
// check if header checkbox is 'true' then update all checkbox with true and update selected records count
// else update all records with false and set selectedCount with 0  
if (selectedHeaderCheck == true) {
listOfAllAccounts[i].isChecked = true;
component.set("v.selectedCount", listOfAllAccounts.length);
} else {
listOfAllAccounts[i].isChecked = false;
component.set("v.selectedCount", 0);
// update the checkbox for 'PaginationList' based on header checbox 
for (var i = 0; i < PaginationList.length; i++) {
if (selectedHeaderCheck == true) {
PaginationList[i].isChecked = true;
} else {
PaginationList[i].isChecked = false;
component.set("v.listOfAllAccounts", updatedAllRecords);
component.set("v.PaginationList", updatedPaginationList);
checkboxSelect: function(component, event, helper) {
// on each checkbox selection update the selected record count 
var selectedRec = event.getSource().get("v.value");
var getSelectedNumber = component.get("v.selectedCount");
if (selectedRec == true) {
} else {
component.find("selectAllId").set("v.value", false);
component.set("v.selectedCount", getSelectedNumber);
// if all checkboxes are checked then set header checkbox with true   
if (getSelectedNumber == component.get("v.totalRecordsCount")) {
component.find("selectAllId").set("v.value", true);
getSelectedRecords: function(component, event, helper) {
var allRecords = component.get("v.listOfAllAccounts");
var selectedRecords = [];
for (var i = 0; i < allRecords.length; i++) {
if (allRecords[i].isChecked) {
Java Script Helper
/* doInitHelper funcation to fetch all records, and set attributes value on component load */
doInitHelper : function(component,event){
var action = component.get("c.fetchAccountWrapper");
action.setCallback(this, function(response) {
var state = response.getState();
if (state === "SUCCESS"){
var oRes = response.getReturnValue();
if(oRes.length > 0){
component.set('v.listOfAllAccounts', oRes);
var pageSize = component.get("v.pageSize");
var totalRecordsList = oRes;
var totalLength = totalRecordsList.length ;
component.set("v.totalRecordsCount", totalLength);
var PaginationLst = [];
for(var i=0; i < pageSize; i++){
if(component.get("v.listOfAllAccounts").length > i){
component.set('v.PaginationList', PaginationLst);
component.set("v.selectedCount" , 0);
//use Math.ceil() to Round a number upward to its nearest integer
component.set("v.totalPagesCount", Math.ceil(totalLength / pageSize));
// if there is no records then display message
component.set("v.bNoRecordsFound" , true);
// navigate to next pagination record set   
next : function(component,event,sObjectList,end,start,pageSize){
var Paginationlist = [];
var counter = 0;
for(var i = end + 1; i < end + pageSize + 1; i++){
if(sObjectList.length > i){
counter ++ ;
start = start + counter;
end = end + counter;
component.set('v.PaginationList', Paginationlist);
// navigate to previous pagination record set   
previous : function(component,event,sObjectList,end,start,pageSize){
var Paginationlist = [];
var counter = 0;
for(var i= start-pageSize; i < start ; i++){
if(i > -1){
counter ++;
start = start - counter;
end = end - counter;
component.set('v.PaginationList', Paginationlist);

-Ranjith T [12/19/18]