Skip to main content

Posts

Lightning : Share common code across multiple components

With more and more complex components being built into lightning, it becomes quite important to understand how we can improve our codebase and ensure that we use best practices. When it comes to building lightning components, they are expected to be pretty much self-contained. It works well when creating standalone components serving specific business function. But, often in enterprise arena we build components having some of common functionality. For e.g. need to validate email or address or a specific business rule validation. A direct approach is to copy and paste the method within helper files of lightning component. But, it is definitely not an advisable approach. So, we have a problem to solve. Lightning provides capability to load external javascript files (static resources) and use it's code. In this article i'll give a quick and simple glimpse of this capability Step 1 - Create a javascript helper file Create a javascript file to contain required shared code...

Sneak Peek: What is Visualforce Viewstate? and how to keep it lean

Note: The main content for this blog post was shared by my friend and colleague Shriram Kabra. There are loads of blogs and articles around managing viewstate in Visualforce pages. As you would know, viewstate is primarily a serialized form of controller state between postbacks. It is very helpful to retain controller's state between client's browser and server. How viewstate works? Every time user opens a visualforce page, Salesforce executes related controller(s). As per controller logic, data is retrieved/ created within memory. This data can also be considered as controller state. If you monitor the lifecycle of Salesforce object (object of controller), it ends as soon as it responds to browser and loses its state. Technically, all subsequent requests for it are fresh page loads. In order for visualforce to retain this state between all postbacks, it needs to store this state somewhere. This is where Viewstate comes handy. While rendering visualforce page,...

Sneak Peek: Visualforce with Javascript Promises

While working with Visualforce pages along with javascript remoting functionalities, we often create a lot of callback methods. On top of it, multiple invocations in a chained approach is more chaotic, often hardcoded and leaves code quite unreadable.   Following is an example code while using Javascript remoting within Visualforce page:-   function invoke_remoteService1 (){ console .log ( ' Invoking remote service 1' ); Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.testWebServiceController.remoteService1}' , remoteService1_ResponseHandler); } function remoteService1_ResponseHandler (response, event){ console .log ( ' Response from remote service 1 = ' + response); if (response ! = null ){ console .log ( ' Invoking remote service 2' ); Visualforce.remoting.Manager.invokeAction( '{!$RemoteAction.testWebServiceController.remoteService2}...

Quick Tips: All about sending emails from Salesforce (with advanced features)

Emails are still a very essential part of our day to day communication. Be it an internal communication within the organization, or across organizations or between customers and organization, emails are one of the key communication mechanism (let's not debate on pros and cons here). Quite obviously, Salesforce provides various options to send emails to internal and external recipients. In this post I'm trying to cover all the essential points (briefly) involved in sending emails from Salesforce. Defining Email Templates First and most important aspect regarding emails is ability to create email templates within Salesforce. This is without doubt one of the most used aspect related to sending emails. Email templates help administrator create pre-defined email templates within Salesforce. This helps in providing business approved and verified templates to system and users. As a result, all outgoing communications are consistent. Also, any correction/ improvement incorporated ...

Quick Tips: Some things about Salesforce Validation rules you may not know

What are validation rules? While creating any application, one of the most crucial building block is clean and good data. We do get ability to define required fields on field and page layout level, but there can be complex scenarios where the business rule needs multiple fields to ascertain data quality.  Salesforce provides a very helpful feature called "Validation rule" to ensure administrators/ developers can create custom validation rules on Salesforce objects. These validation rules help ensure that any record being created or updated qualifies to defined business rules. If not, then developers/ administrators can display required error message. Validation rule constitutes of:- Formula - formula to evaluate business rule. If formula evaluates to TRUE, validation error is thrown, else it's considered as validation success Error message - error message to be displayed on validation failure Location - Enables admin/ developer to define location to displa...

New Salesforce Book - Apex Design Patterns

  Refer below links to purchase: Packt publications Amazon.com (US) Amazon.in (India) Amazon.co.uk (UK) I'm really excited to share that today my book (co-written with Jitendra Zaa ) has been published. Here are some personal insights A little history This particular topic was always in my head and coming from .Net background and having worked with lots of design patterns in MS development world. I first successfully used Factory design pattern with Apex in 2009, when all my team was scratching their head and (cursing me badly) for "overtly complicating" the code architecture. They were happy with creating 20-30 different VF pages, which I emphasized needs to be designed with the help of 4-5 VF pages, VF components and factory method pattern. Well, we were able to complete the whole stuff in time and deliver it flawlessly. It was then and similar instances later that I realized that a larger faction of Salesforce developers (back then) had very l...

Quick Tips: Un-clutter Report type list (hide report types)

Frankly, this is a pretty nifty feature I have just observed (never paid attention) and I thought that most of you like me, would have never looked into it. So, hereby sharing it. While implementing Salesforce, one of the key things we showcase to users is the ease with which users can create their own reports with point-and-click features. This is definitely a very important feature for end users as they get the power to create reports in minutes without having to wait for lengthy IT process. Vanilla Salesforce provides lots of report types out of the box as per below screenshot. However, it is quite common that client might not be using certain features of Salesforce and hence those report types are not being used at all. They just clutter the report type list unnecessarily. Salesforce provides a quick way to hide unwanted report types. Just, check the checkbox above "Select Report Types to Hide" and you can hide/ unhide report types. For e.g. we want to hide all...