Posts

Showing posts from August, 2018

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=&qu

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&quo