Posts

Showing posts from March, 2017

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

New Way of Pagination

Image
   In salesforce there are 2 ways to achieve pagination. 1) Using StandardSetController (Limitation : To instantiate              StandardSetController we can query up to 10000 records using query     locator.   Querying more than 10000 records causes a LimitException to     be thrown.     However by passing list of more than 10000 records we can instantiate     StandardSetController, again holding more records in the List and instantiate StandardSetController can reach heap size. ) 2) Using OFFSET in SOQL query (Limitation : We can skip max 2000     records using OFFSET which means we cannot do pagination by using     OFFSET if the query skips more than 2000 records. Skipping more than     2000 records causes "Maximum SOQL offset allowed is 2000 error" . )         Here is a new way to achieve it. Hold records you need to display     by   pagination  in List of List of SObjects (i.e List<List<SObject>>).     Where the size of List<SObject>