Posts

Two Columns Multi-Select Picklist Lightning Component

Image
Note : From API Version 41.0 and later you can use lightning:dualListBox for the same. for more information refer  Lightning component developer guide Two Columns multi-select is one of the frequently required functionality in web development. MultiselectPicklist is a Lightning Component developed for the same. It can be used easily in lightning components as well as in visualforce pages. Component Name: MultiselectPicklist Required Attribute: name=availablePickList, type= String [] Usage: In Lightning component / Lightning App : Syntax :  <c:MultiselectPicklist availablePickList= List of picklist/> Eg. <c:MultiselectPicklist availablePickList="['spray', 'limit','elite', 'exuberant', 'destruction', 'present']"/> In Visualforce Page : To use this component in Visualforce page, create an App which extends ltng:outApp. Set Dependency In Lightning App. Refer TestApp Test

Uploading multiple files as attachments using chaining of actionfunction in single click.

Image
File operations in salesforce are not easy compared to other technologies because of it's governance limits like maximum heap size, maximum string length etc.This post will be explaining how to upload multiple files with single browse by chaining of actionfunction using JavaScript. Limitations of apex : i nputF i le:  1) apex:inputFile cannot be used in conjunction with an action component, apex:commandButton or apex:commandLink that specifies a rerender or oncomplete attribute. So this tag is not useful on complex vf page. 2)This tag can upload only one file at a time. Implementation: In JavaScript function uploadFiles converts attachments body in base-64 encoded string and calls actionFunction saveFileAF(Base64 Encoded attachment body, File Name). In Apex decode base64 string and create attachment. On complete this  again call uploadFiles function in JS for next file. Repeat the same operation for each file. Code:                                                 

Visualforce Componets

Image
Code reuse is one of the best practice in coding.  We reuse code while writing code in Apex by creating functions and calling it wherever required, but how to reuse code when it comes to Visualforce? Well the answer is   Visualforce Component . We can create Visualforce Component , pass parameters to it and use it wherever required. Visualforce Component may or may not have a controller. Component Syntax: <apex:component > <apex:attribute name="ComponentAttributeName" type="String" required="true"/> <apex:outputText   value="{! ComponentAttributeName }"/> <apex:component > Attribute type can be String, Integer, Boolean,  sObject, List or Class                 Syntax to use Component : <c:componentName ComponentAttributeName="Value"/> Visualforce Component can be used in Visualforce page or other Visualforce Component. Let’s implement an application and use Visualforce Compon

Dynamic Visualforce Bindings with Example

Image
This blog will be explaining how to use dynamic Visualforce bindings with example. Sometimes we have to build Visualforce pages based on certain conditions or based on user input, i.e fields on page are determined at run time rather than compile time, In this case rendering based on conditions is not enough to achieve the goal. At this point dynamic Visualforce bindings come into the picture. In dynamic Visualforce bindings along with user input there are methods and properties of the controller that determine how to assemble a new page. Syntax : reference [expression] We can use dynamic binding in formula expression on Visualforce like {!reference [expression]} Where reference can be Sobject or Apex class, expression can be name of the field or object which recursively returns field. In this blog we will be creating Visualforce page for case creation and fields on the form will be decided at run time based on fields selected form will be created. We will show on

Send SMS using Twilio Salesforce Library

Image
SMS is still one of the best way to connect with customer . This blog will be explaining how to use the twilio-salesforce helper library to send SMS. As usual we will implement a small application for it. We will add “Send SMS” button on Account. After clicking “Send SMS” button Salesforce user can type message and send to phone number of that Account. Steps: 1) download the twilio-salesforce library from GitHub.   2) If you don’t have Force.com migration tool install from here . 3) Extract downloaded twilio-salesforce zip file and edit i nstall/build.properties   to insert your Salesforce username and password. append security token to     your password.    Open command line to the install folder, then deploy using Ant:          Command : $ ant deployTwilio 4) Sign up for twilio account by trial pack you can send SMS to verified phone      numbers only.      (If you need you can get paid service so you can send SMS

Component Events in Lightning

Image
This blog will be explaining how to use component event in lightning component by implementing simple search application for Accounts. There are two types of events Component Event : Component event can be handled by any component which is above event firing component in the containment hierarchy. It is best practice to always try to use component event, if possible. Component events can only be handled by components above them in the containment hierarchy so their usage is more localized to the components that need to know about them. Application Event : Application event can be handled by any component where handler is provided. Application event is used where components are different parts of application and there is no containment hierarchy. Lets implement simple searching application with two components and communicate between components by a component event. We have following components and events. 1) eventAccount (event): This is a component eve

Pagination In Lightning Component

Image
This blog is a continuation of ‘Dispalying Data Table in Lightning'.  If you haven't read that blog and want to read click here . In that blog we simply queried Accounts and displayed on lightning component.    The Salesforce Lightning component framework uses a stateful client and stateless server architecture. So we need to take a slightly different approach to do pagination than traditional VF. In order to maintain the value of offset. This is how we are doing. In Server Side Controller: We have a wrapper class AccountWrapper which wraps Accounts need to be displayed in accList, hasNext, hasPrev and offset. Server side action returns instance of AccountWrapper. In Client Side Controller : We have 4 action functions       1)  doinit  : This action function invokes on page load. Querying accounts with default page size.       2)     prev  : This action function invokes after pressing Prev button.       3)     next : This action function invoke