Use Visualforce in Classic and Lightning Experience

How to design a Visualforce page so that It would be displayed properly in classic as well in Salesforce Lightning Experience

This topic was subset of my presentation in Salesforce Boston World Tour 2017. Sometimes we find our-self in situation where custom Visualforce page should be displayed with Old theme in classic but with Lightning theme in Lightning Experience.

If you can convince client to use same user interface in classic and Lightning, then it would be an ideal approach. Even Salesforce displays classic user interface for many setup pages inside Lightning experience.

If client does not agree, then we simply need to detect that in which context Visualforce is running and then enable or disable the section as per UIThemeDisplayed global variable as shown in below Apex code snippet. Continue reading “Use Visualforce in Classic and Lightning Experience”

Performing Load Testing in Salesforce using Selenium and TestNG

Parallel execution of browsers in Selenium with the help of TestNG and determining maximum operating capacity of custom code in Salesforce

When we build any custom solution in Salesforce, key is to write an efficient and meaningful Apex test classes for sure. However sometime we may need to test how custom application would behave in maximum operating capacity. Here, I am talking about Load Testing of custom applications built on top of platform. Recently I needed to push my code to its limit to know how many concurrent users can use it before hitting any governor limits. Quickly I realize that its time to call my friends Selenium and TestNG.

Before doing any extensive stress or load testing on Salesforce, we must need to contact Salesforce support and explain them what we are trying to achieve. More detail available in this official Salesforce blog post.

I have published some blog posts about Selenium in past as well however whats different this time ? I need to determine after how many simultaneous user interactions, I would hit Concurrent Apex Limit error as shown in below image.

Salesforce Governor Limit error - Concurrent Apex Limit
Salesforce Governor Limit error – Concurrent Apex Limit

Continue reading “Performing Load Testing in Salesforce using Selenium and TestNG”

Housie / Tambola / Bingo Game Number Generator

Author posted by Jitendra on Posted on under category Categories Others and tagged as Tags with Leave a comment on Housie / Tambola / Bingo Game Number Generator

Online free Housie / Tambola / Bingo Game. Simple to use and play with Bingo Number descriptions

Its not education , technical or Salesforce related post. Its source code of Family fun game Tambola.

Free online Tambola Game
Free online Tambola Game

This weekend, we all friends gathered together to play one of most famous Indian game Tambola. This game is also known as Housie or Bingo.  Normally there is central pot where numbers between 1 to 90 placed in piece of paper or plastic balls. Host reveals numbers one by one by randomly selecting those balls or piece of papers from pot. Problem for us were, we all have children and there is no way they will allow us to play with this way. Instead of host picking numbers, our kids would have been played with those. So what I did is, simple HTML page with random number generator between 1 to 90. Plugged my laptop to chromecast and voila, everyone in room playing traditional game in modern way 😉 Continue reading “Housie / Tambola / Bingo Game Number Generator”

Lightning Data Service – Standard Controller for Lightning Components

Best Practices for Salesforce Lightning Component. How Lightning Data Service can improve Lightning Component performance and solve inconsistent data problem without writing single line of Apex code. Demo source code, image and slides included.

If you have worked on Visualforce and started playing with Lightning Component, you must have identified one important missing feature, which is standard Controller.

Lets assume a scenario, you have two Lightning Components on Account page. One Lightning Component is used to show some fields and other component is used to edit same record.

Problem 1 :

To achieve this, both Lightning components would invoke Apex method separately at the cost of performance, by issuing duplicate server calls. Below image depicts problem, where multiple Lightning component requests same content by making separate server calls.

Lightning Components - Duplicate Server Calls
Lightning Components – Duplicate Server Calls

Continue reading “Lightning Data Service – Standard Controller for Lightning Components”

Lookup component in Salesforce Lightning

Author posted by Jitendra on Posted on under category Categories Salesforce and tagged as Tags , with Leave a comment on Lookup component in Salesforce Lightning

Salesforce Lightning component in plain JavaScript and SLDS with complete source code

Salesforce comes up with many out of box UI components and Lightning Base components. However, one important component missing is Lookup component or Type ahead component in Lightning. There are some lookup components available however either they are using some JavaScript library or UI doesn’t match with Salesforce Lightning Design system. So, I wanted to have something similar used by Salesforce Lightning interface itself and come up with this component. Complete source code of this component can be found on my Github repository also.

Before, jumping directly to source code, lets first discuss some important points. Continue reading “Lookup component in Salesforce Lightning”

Use Hierarchy custom settings to avoid hard coding in formula field, custom button, process builder or workflow rules

Example of using Hierarchy custom settings in formula field, custom button, process builder and workflow rules. Youtube video included.

Avoiding hard coded Ids or values from formula field, custom button, process builder, Workflow rules or Approval process using Hierarchy custom setting is not something new. This idea exists from many years in Salesforce ecosystem. However, some times I have seen developers and admins debating on same question, so though to put a consolidated blog post on same.

Why you should avoid hard coded values or Ids in Salesforce ?

Answer is very simple, maintenance. When sandboxes are refreshed or metadata deployed to different instances, admins would need to change values manually. If we are talking about manual post deployment step, then we are also talking about nightmare of maintaining list of manual post build steps.

Can we use Custom Labels to avoid hard coded Ids / values in Salesforce ?

Technically yes, but I would suggest not to use custom labels in Salesforce to avoid hard coded Ids because of below Issues

  •  Dataloader does not support custom label bulk load / restore / export
  • Imagine there are 100’s of custom label and it needs to be different for each Salesforce instances. You would be left either with manual step or some external tool which may not be allowed / approved by customer.

Hierarchy Custom Settings to Rescue

If you are from Java / C#, consider Custom setting as resource file. Here, you would store information about your application which doesn’t change frequently and controls behavior of application. There are two types of custom settings

  • List Custom Setting
    • This custom setting is equivalent to custom / standard object. We can store values in tabular format.
  • Hierarchy Custom Settings
    • This custom setting can be used in formula field, process builder, custom button, Workflow rules or Approval process.
    • Most unique feature about Hierarchy custom setting is that we can have different values at Organization level, profile level and user level.
    • Custom setting can be used in formula fields using global variable $Setup. Syntax to use custom setting is
    • Highest priority is given to value defined at user level then profile and at last organization level.

Continue reading “Use Hierarchy custom settings to avoid hard coding in formula field, custom button, process builder or workflow rules”

Show Lightning component on public website without authentication

How to show Lightning component on public sites without need of user authentication

I have posted few articles on Lightning OutIn this post, we will see how Lightning components can be displayed on public website. To access these Lightning components, users don’t need to login to Salesforce.

For this post, I will consider Text slider component created in this post. Using this same method, I have displayed Live demo of Lightning component on wordpress blog. Continue reading “Show Lightning component on public website without authentication”

Text Slider Lightning Component for Salesforce with Live Demo

How to use Nested Components and create a simple yet powerful Text Slider Component in Lightning for Salesforce

In this post we will create simple and powerful Text Slider Component in Lightning.

Below are list of all features supported by this Component

  • Its pure CSS based without any JavaScript libraries therefore super fast
  • Long contents are auto scrolled with nice overloaded CSS for scroll bars
  • Ability to set Header and Body Text for each slides
  • Enable or disable auto background colors
  • Enable or disable auto slideshow
  • Control slides delays in case timer enabled
  • If auto background color turned off then ability to control background and text color
  • Slider contents are un-escaped means we can render richtext content

Continue reading “Text Slider Lightning Component for Salesforce with Live Demo”

Design Continuation Server in Salesforce

How to implement Continuation Server in Salesforce with the help of Action Function and Continuation Object

Continuation Server using ActionFunction in Salesforce
Continuation Server using Action Function in Salesforce

If you are new to Continuation Object in Salesforce then would suggest to read introduction post first. In last post, we discussed how to implement limitless chaining of Continuation Object using JavaScript remoting. In this post, we would try to achieve same, but instead of using JavaScript remoting, we would be using ActionFunction.

Why do we need chaining of Continuation Object

  • From Apex, we can only chain 3 Continuation Object
  • If we call API synchronously, chances are very high that it will run for more than 5 sec and contributing towards Concurrent Apex limit
  • Getting CPU timelimit error is also high
  • Making synchronous call also means risking scalability of Salesforce instance
  • You don’t want user to wait till call out completed, let them work and update user interface once response is received

Continue reading “Design Continuation Server in Salesforce”