Posts

Salesforce Lightning: Password Strength Meter

Image
Today we will have a look at how to create a lightning component which analyses the strength of your password. The component only uses the standard lightning tags and no external JS library has been used to achieve this functionality. The functionality is handled completely at the client with no apex code, which makes it performance centric. To allow the user to enter password, I have used lightning:input with type="password". There is an ochange event configured on this input element which makes a call to JS controller and analyses the password. Once the analysis is completed, it sets a score for the entered password. To display the strength of the password, I have used below 2 components: lightning:slider lightning:progressBar Both the components use the score which is set by the controller method. If you want to add some chart which displays the strength, you can use JS libraries like chart.js. PasswordStrengthMeter.cmp <aura:component implements=...

Winter 19: Top Features

Image
Winter 19 has a lot of new features released which provides more flexibility while creating apps in Salesforce. Here are some of my favourite features: New component lightning:map Before Winter 19 release, to display a map, you need to use external JS library like Leaflet. But with Winter 19, maps will be supported by the platform using lightning:map. This tag is similar to the apex:map tag available in Visualforce page. New attribute in lightning:accordion Before Winter 19 release, the default behaviour of accordion was that only one section can be opened at a time. If you want to open all the sections at once, it was not supported. The workaround was to use html accordion instead of lightning accrodion. But now with Winter 19, Salesforce has introduced a new attribute called allowMultipleSectionsOpen. If this attribute is set to true, then all the sections can be opened at the same time. Mark Apex Method as Cacheable As mentioned in my last blog, the current solution to...

Salesforce Lightning: Client side caching using Storable action

Image
Worried about the performance of your lightning components? Frequent calls to server are degrading the performance of your lightning components? If yes, then the answer to all such problems is Storable actions. Storable actions in lightning are a way to cache your data at the client side. This is all internally managed by the platform and minimal custom code is required for this. To make an action storable, you simply call its setStorable() function. For example: var action = component.get("c.getPicklistOptions"); action.setStorable(); action.setCallback(this, function(response) {     // handle response }; $A.enqueueAction(action); How does Storable action works? If you call the setStorable method before calling the server side method, then the platform compares the previous server call with the current server call. If the parameters to both the server calls are same, then it skips the server call and instead returns the response from the client side cache. Th...

Salesforce Lightning: Dependent Picklist - State Country picklist

Dependent picklist are not supported by default in the lightning components. There is no component provided by Salesforce through which we can have dependent picklist in custom lightning components. Fot this example, I have created two custom fields of type picklist - Country and State on Account. After creating the fields, I have setup dependency between them where Country is the controlling picklist and State is the dependent picklist. Below are the components used: Picklist.cmp - Generic component to display picklist in lightning component. Just pass in the object api name and field api name to display the picklist. StateCountryPicklist.cmp - This component displays the state values as the per controlling country value passed to it. Below is the code for all the components: StateCountryPicklist.cmp <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId" access="global...

Salesforce: Automate creation of Change Set using Selenium

Have you ever been involved in creation of change set for a release? If the number of components are high, then creation of change set becomes a time consuming process. And then the same change set creation has to be replicated across all the env: dev, QA, UAT and finally on Staging. To avoid all the manual work and save time, I have automated the creation of change set using Selenium. You just need the provide the name of your components in a property file and the application will take care of creating the change set. Currently the application is limited to 3 types of components: Apex class, VF page and Triggers and I will be enhancing it soon to support most of the component types. To use this application, create a new Java project in eclipse and follow below steps: 1) Copy following classes in src/main folder:     a) ChangeSet.java     b) ChangeSetUtils.java     c) SeleniumUtils.java 2) Create a file named config.prop...

Automate data backup of Salesforce org

Image
Salesforce provides a feature called "Data Export Service" through which you can generate backup files of data on a weekly or monthly basis depending on your salesforce edition. You can export all your org’s data into a set of comma-separated values (CSV) files. The sad part over here is that this feature in not supported in Sandbox yet. Developers frequently have the requirement to take the data backup of sandbox org, especially if they are working with a managed package.  Here is a batch class which will allow you to take a backup of your entire org data and store it under Notes and Attachment under a custom Backup object. In the next blog, I will enhance this code to store the backup in Google Drive instead of storing it in a custom object in org. Here are the steps you need to take to make this work : 1) Create a custom object in your org whose API name should be  Backup__c 2) Create below batch class in your org global cla...