Modern JavaScript

Originally named as “LiveScript” but later launched as JavaScript, owing to the popularity of the technology at that time, it has become one of the most popular programming languages. JavaScript has been evolving over the last two decades. However, until 2015, JavaScript did not have too many enhancements. The JavaScript version most developers are familiar with - ES5) - was published in 2009. Over the last few years, JavaScript has evolved rapidly and the version that we are using has become an old-school version (most of the developers call it “The Dark Ages” of the JS!). So let’s get up to the speed quickly and learn some cool new features of ECMAScript 2015+ also popularly known as ES6+. let In the old-school, we were using ‘var’ to declare a variable. That has a huge loophole in the architecture and its behavior. Sometimes it becomes a bottleneck for the developers because ‘var’ does not support block scope. To understand the block scope, see the following piece of scr

Retrieve IP Address for the Guest Users in Lightning Community

Recently, we received a requirement where we needed to track the IP address of the guest users on the Salesforce Lightning Community. One of the ways to get the IP address of the current user in Apex is using the following method: Auth.SessionManagement.getCurrentSession().get('SourceIp') But this method works only for logged in users and gives an error for the guest users. We tried getting the IP address from the cookies also, but it's not a good idea because it is really not necessary that for guest users, you will get the IP address in the cookies always. At last, we came up with the following workaround to solve this riddle: 1) Create the following apex controller (ViewIPAddressController):  public class ViewIPAddressController{     public String ipAddress{get; set;}     public ViewIPAddressController(){         //this will work if no caching is in place or         //user is logged in via secure URL         ipAddress = ApexPages.currentPage().getHeade

Incremental/delta data export using command line data loader

A few months back, we got a requirement for hourly incremental/delta export of data from Salesforce. There was a restriction that we didn't want to purchase any other licensed ETL tool, so we decided to use the command line data loader using that export can be scheduled also. Command line data loader requires SOQL to export the data, so to export the data hourly we scheduled the process using windows scheduler for every hour, but the main challenge here was to write a dynamic SOQL that would apply a filter to extract the records for those created date is greater than last 1 hour. Salesforce does not provide any SOQL datetime literal like LAST_1_Hour or LAST_N_HOUR. There are 2 methods to accomplish the requirement. First is using powershell script and the second is using SOQL itself. Method 1 - PowerShell Script In command line data loader, process-conf.xml contains the SOQL, so in case of an hourly incremental data extract SOQL will be like SELECT Id, Name FROM Contact

Visualforce header and sidebar do not appear on IE11 (or lower version of IE) even when enabled

Recently, we rolled out lightning experience for a Salesforce org and encountered an issue in classic experience for IE11 or lower version of IE. IE11 does not support lightning experience by default. To enable lightning experience in IE11 following is the setting in "Setup >> Session Settings" that needs to be enabled: As clearly explained in the above snapshot, Salesforce does not recommend this setting to be enabled, so we decided not to enable the lightning experience for IE11. Now when users login to Salesforce in IE11, they can access only classic experience. So the issue is, when they open any VF page in IE11, header and sidebar are not visible even when showHeader and sidebar are set to true. As per Salesforce documentation this is because, when customer switches to lightning, the flag UserPreferencesLightningExperiencePreferred is updated for the affected user. And if the setting "Extended use of IE11 with Lightning Experience" is unchec

Email Alert to Parent object's email field without apex

Workflow! When you hear this term, a fantastic way to automate many business processes comes to your mind. Using workflows in Salesforce, you can do many things and this needs only a few clicks. You can perform various actions using worklow like updating a field, creating tasks, sending outbound messages and email alerts. A few years back, we got a requirement in a project where an email notification needs to be sent to opportunity owner and owner's manager if the opportunity stage turns to "Closed Won". So the requirement was simple, we just created a workflow rule with the specified criteria and created a workflow action to send the email alert. wait, wait, wait!! It was looking simple but while adding recipients to the email alert, we got stuck. There is a limitation associated with workflow email alert, we can add email fields as recipients if those are on the object for which we are creating workflow. In our scenario we needed to send email alert to the owner'

Salesforce Voice Assistant

Install the chrome extension using following URL:

Upload a File as Large as 2GB in Salesforce Using a Visualforce Page

 Listed in Top 20 Salesforce Articles of 2016  by Rainforce (WalkMe) Recently, we got a requirement in a project to upload a file into Salesforce that could be as large as 2GB, using a Visualforce page. We created a Visualforce page and used the apex:inputFile component, but received an error upon upload because apex:inputFile has a limitation. The largest file size users can upload with Visualforce is 10MB. This posed a big limitation for the requirement. We used a different approach to meet this requirement. This is a tricky problem to solve, and needs some jQuery stuff. We decided to use the chatter:feed component in a Visualforce page. This component embeds Chatter in the Visualforce page, and allows users to upload files as large as 2GB as Chatter feed in Salesforce. It’s just as pictured below when we upload a file using this component: As for keeping track of th