Send Visualforce as an email attachment from Apex Trigger – Alternate design

Process Builder & InvocableMethod- Alternative to send Visualforce as an email attachment from Apex Trigger

Previously I had written same blog post and it was working fine before Winter 16. However, after Winter 16 critical update was released by Salesforce to consider getContent() method as a callout. If this update is enabled in your Salesforce instance then my previous blog post will not work.

In this blog post, we will go through alternate design, where we would still be able to send Visualforce page content as an Email attachment. Difference is, instead of Apex Trigger , Invocable Method and Process builder will help us getting there.

Again, consider below simple Visualforce page, which we want to send as an attachment.

Continue reading “Send Visualforce as an email attachment from Apex Trigger – Alternate design”

Dynamically remove XML content from metadata before Salesforce deployment using xmlTask – Video

Example – automatically remove listview before deployment

Many post about deployment using ANT has been posted on this blog like auto backup complete Salesforce instance daily, upload Salesforce data on FTP Server, auto generate package.xml, continuous integration and so on.

While implementing real Continuous integration in Salesforce, we need to perform various adjustments in metadata before deploying it to build server or production instance, many automated scripts (automation) are needed. If you need to change ANT scripts or metadata frequently, then it means continuous integration or deployment process in your Salesforce project is not yet fully matured.

There could be multiple situation where we don’t want some component to be deployed on production and example of one of them is List view Continue reading “Dynamically remove XML content from metadata before Salesforce deployment using xmlTask – Video”

Twitter’s Like button as Salesforce Lightning Component- pure CSS3 with Video

Building Lightning component checkbox to have Twitter’s Heart like animation without any image or JavaScript.

Twitter uses image sprite and JavaScript to produce Like button animation. We would be giving same effect to checkbox by using Lightning component. Combination of Checkbox, Label and Box property of CSS3 is used to give final result.

Lightning Component will contain only declaration of checkbox as shown below.

TwitterLove.cmp


<aura:component >
<input id="toggle-heart" type="checkbox" />
<label for="toggle-heart">❤</label>
</aura:component>

Note : In above source code, heart UTF icon is getting replaced by emoji code, so refer this screen to see exact code written for Lightning Component.

We have used Sassy CSS (SCSS) in this demo, as it would be little bit hard to write pure CSS with animation. Once SCSS is written, we can use this online tool to convert it to CSS. All these are explained and build live on my channel. Continue reading “Twitter’s Like button as Salesforce Lightning Component- pure CSS3 with Video”

Tips to effectively use Google chrome developer tool

While building Lightning Components in Salesforce, how to effectively use Google chrome developer tools to troubleshoot and analyze issue

Web based applications are dominating the software industry and various frameworks like Angular 2, React, polymer and Lightning are on rise. From movie Spider man, this dialogue stands very true – With great power comes great responsibility.

As a web developer, its our job to make sure the application implemented by us, stands on performance benchmark and at the same time development time is reduced. To achieve this, fast and effective troubleshooting of web application becomes integral part of project development. One of the best tool to troubleshoot web applications are available freely – Google chrome developer tools.

In this blog post, we will uncover lots of tips and tricks about using chrome developer tools.

To launch, chrome developer tools in chrome, use shortcut ctrl+shift+I or ctrl+shift+J. We can directly execute Javascript in chrome dev tools without creating any html or javascript file.

Console API

we will start with console API of chrome developer tool first.

Printing Debug statements in Javascript

we can use various methods of console in javascript to debug our code. Previously, if we wanted to debug JavaScript, alert methods were mostly used however they were very annoying. Below code snippet shows available methods to print debug statements in chrome console.

<script> 
	console.error('Google chrome dev tools - error');
	console.warn('Google chrome dev tools - warn'); 
	console.info('Google chrome dev tools - info'); 
	console.debug('Google chrome dev tools - debug'); 
	console.log('Google chrome dev tools - log');  
</script>

Below is output, how its displayed in chrome

Console.log levels
Console.log levels

As shown in above image, different log levels of console method printed in different color. error log level even prints complete stack trace of methods showing origin of error.

Continue reading “Tips to effectively use Google chrome developer tool”

Salesforce Summer 16 – My favorite top 20 features

List of Salesforce Summer 16 features

Summer 16 is already in production and most of you already knows what’s there in pandora box. In this post, I will share my favorite 20 features of Summer 16 release.

Salesforce Summer 16
Salesforce Summer 16

1. Clone Sandbox (Pilot) : This feature is not yet generally available however worth mentioning. Till now, we could create Sandbox only from production, however Summer 16 gives us a way to create brand new sandbox from other existing sandbox instead of production.

2. New Trace Flags in Debug Log : Now we can add trace flags on Automated Process, User, Apex Trigger and Apex classes as well. Before this release, we could only add trace flag on user. This enhancement will give developers more control over what to display in debug log and overcome debug log size limit problems.

Salesforce Summer 16 new Debug logs

Continue reading “Salesforce Summer 16 – My favorite top 20 features”

Five important configuration in Service cloud console layout – Video

Video tutorial explaining basics of Service cloud console and configuring important features

Many times I struggle to remember how to configure some components in Service cloud because, there are many features which has been disabled. Many new feature needs some extra configuration to enable it. For example, like to enable Knowledge One, we need to disable traditional article component

This video explains some of basics of configuring Service cloud console in Salesforce.

Below are topics covered in this video :

  1. Setting up Highlight Panel
  2. Enabling Knowledge One component and auto search article on basis of Subject entered
  3. Disabling related list on left panel
  4. Adding service console component on left panel
  5. Enabling Interaction log

Continue reading “Five important configuration in Service cloud console layout – Video”

Lightning component code review using CLI – Video

Video tutorial explaining how we can use Lightning CLI to identify possible issues and enhancements needed for Lightning Component and enabling it for Locker Service

Lightning CLI is code linting tool, which can be used to validate source code of Lightning components (Javascript files only). This tool is made specially keeping Locker Service in mind where we can validate if Lightnign component is breaking any contract while trying to access DOM element out of its own scope.

Lightning CLI is based on open source project ESLint. Below video demonstrates how we can install Lightning CLI and use it for existing Lightning Components. You can subscribe to my youtube channel to get latest update on Salesforce related videos. Continue reading “Lightning component code review using CLI – Video”

Batch Apex – First error: Apex CPU time limit exceeded

Author posted by Jitendra on Posted on under category Categories Salesforce and tagged as Tags with Leave a comment on Batch Apex – First error: Apex CPU time limit exceeded

Lessons learned while fixing error in Batch Apex , First error: Apex CPU time limit exceeded

In this post, I would share my recent experience in fixing “CPU time limit” error in Batch apex and reason. When I encountered this error, initially thought that it would be easy to fix by following some of basic rules like :

  1. Remove unnecessary code and loops
  2. Efficient use of collections (Set, Hashmap or List)
  3. Avoid using loop within loop
  4. SOQL query should be indexable
  5. Avoid unnecessary re-initialization of variables
  6. Use Aggregated SOQL (as Database operations not counted in this limit, avoid arithmetic operations in Apex)
  7. Check how much time Workflow rules and process builders are taking
  8. Is there any manage package performing heavy operations in transaction

This piece of code was handed over to me from previous team, so I was not fully aware about full functionality and thought to check debug logs. To my surprise, how many times I tried to get a log, every attempt failed. I was thinking that problem could be in execute method however Batch Apex was failing with no debug logs. I tried all my tricks to get debug log with no success.  Batch Apex was using Query locator and it could fetch up to 50 millions of record and therefore overlooked start method. Continue reading “Batch Apex – First error: Apex CPU time limit exceeded”

Summer 16 – Process builder with multiple decision criteria

Summer 16 release of Salesforce brings festival of lights not only in its logo but to Process builder as well

Before going to this feature, lets try to outline problem first. Consider a situation where we need to create a task when lead  source is Email and send an email to owner if lead source is Email and company name as ABC.

If we try to solve it using process builder, very soon we will understand that it is not possible in one process builder. Process builder can have only one criteria with true and false condition. In previous process builder, we could either perform action if lead source is Email or lead source is Email and company ABC. There is no way to define new criteria which will run along with previous criteria as shown in below image.

Process Builder Before Summer 16 with Single descision criteria
Process Builder Before Summer 16 with Single decision criteria

Continue reading “Summer 16 – Process builder with multiple decision criteria”

Guide to setup Omni Channel in Salesforce with Video

Step by step guide to know about Omni Channel and how does it makes Call Centre Queue Manager’s life easier in Salesforce Service Cloud

We can route case or lead records to Queue on basis of assignment rules. Queue can also be set as an owner for custom object records. However, once record is assigned to queue, it needs manual intervention to assign it further to members in queue or queue member can assign to themselves. Queue members assigning to themselves, however may result into cherry picking. Some agents may resolve easier cases and some of them only gets time consuming or hard cases.

Omni-Channel offering from Service cloud is promising product and resolves this problem to some extend. It can automatically route records to agents in queue on basis of incoming case complexity and work load of agents.

Omni-Channel in Salesforce
Omni-Channel in Salesforce

In this post, we will walk through steps to set up Omni-Channel. Continue reading “Guide to setup Omni Channel in Salesforce with Video”