Video – Large Data Volume – How Lightning Platform Query Optimizer Works

Best Practices of handling Large Data Volume (LDV) in Salesforce

Last year I presented how Query Optimizer works in Kitchner developer group. Found myself coming back to slide multiple times, so thought its good idea to post all information in this post.

Getting Started with Lightning Web Component

Before starting with Lightning Web Component, I would suggest to read this introduction post first.

If you enjoy watching video then you might enjoy below video where I conducted Live coding explaining basics of Lightning Web Component.

In this post, we are going to Show loading image on initial load of LWC. In background we would be calling Apex class to take decision if loading image should be hided or redirect user to some other page.

Continue reading “Getting Started with Lightning Web Component”

Cannot change both ‘UnitPrice’ and ‘TotalPrice’ in update call

Trigger to change UnitPrice in Salesforce

Recently, I was in need to update Sales Price (Unit Price) for OpportunityLineItem using Trigger. I wrote a small trigger on before insert and before update of OpportunityLineItem to update Sales Price.

It worked fine on insert however on update, even if user clicked on update button without changing any value, we were getting error Cannot change both ‘UnitPrice’ and ‘TotalPrice’ in update call.

Its Standard Salesforce behavior and seems in background platform tries to perform some calculation for Total Price which is Quantity * Sales Price. I was not able to get it working on before update. However, below two approach worked :

  1. Use Process builder to compute Unit Price as per formula. Process builder field update works after trigger so it went through.
  2. In after update trigger, create list of Opportunity Product to be updates and make explicit update call for all records which qualified for update.

Enterprise Territory Management – Key Notes

How to use Apex based sharing to share opportunity using Territories

  • Enterprise Territory management is used to share Account and its related opportunity and Cases.
  • Account can have multiple Territories.
  • User can have multiple Territories
  • Opportunity can have only 1 Territory. Think about it – If Opportunity allowed to have multiple Territory, how revenue would be split between multiple Territory and what would be business rules ?
  • Territory enables “My Territories” and “My Team’s Territory” filter in Account and Opportunity list View.
  • While creating Territory, we can decide access to Account, Opportunity and Case. Depending on OWD, access can be private, read only and read write.
  • Enterprise Territory Management does not support overlay forecast unlike Roles. However we can create report on Opportunity split object.
  • Overlay forecast (Revenue sharing) is not supported because Opportunity can have only one territory and therefore only 1 revenue maker.
  • Maximum Territory that can be defined is around 99k unlike maximum role 10k.
  • Custom Field (but not lookup) can be created in Territory2 object.
  • Territory related list appears on user and Account records.
  • You cannot create lookup to Territory objects.
  • Territory to Opportunity can be assigned using Apex class plugin

Enable Territory based Forecast

  1. Mark user as “Allowed Forecast”
  2. Add user as Territory Team member
  3. Add user as Forecast Manager in Territory

Apex Based Sharing of Opportunity using Territory

For Apex based sharing, we use user of public group Id to share record. If we want to share Opportunity using Territory then there is quick code for that. If we click on manual share button on Opportunity, it will show an option to choose between user, public group, territory and territory with subordinates.

There is no clear documentation, but what I found that when we share using Territory, Salesforce internally creates public group for that territory and assigns that public group to Opportunity.

So, first step is to find public group created for territory. Below code showcase how it can be done.

References :

Introduction to HTML Web Components

Pillars of HTML Vanilla Web Components

Modern browsers have become so advanced and powerful that there is almost no or minimal need of Javascript libraries these days. There was time when web developers rely heavily on frameworks like JQuery, Angular or React. Same for Salesforce, when it launched Aura framework in 2014.

In last 5 years, web browsers have evolved so much that we need to revisit and check ourselves that do we really need libraries or frameworks for every small functionalities ? Considering rich feature set browsers, Salesforce already revisited aura framework and decided that it’s time to make it more lightweight and use native browser capabilities as much as possible. Welcome Lightning Web Components !!! Before we jump into ocean of Lightning Web Components, it’s important to understand what is supported by browsers natively ? Out of many features supported by modern browsers, one of most important one is Web Component.

Below are 4 pillars of Web Components

  1. Templates
  2. Custom Element
  3. Shadow DOM
  4. Imports
Continue reading “Introduction to HTML Web Components”

Docker Cheat sheet

Author posted by Jitendra on Posted on under category Categories Salesforce and tagged as Tags , , , , with Leave a comment on Docker Cheat sheet

Frequently used docker commands and cheatsheet

Refer this url to get official cheat sheet for docker commands. Below are some of frequently used commands by me

Find all docker images installed on system

docker images

Find container id of currently running dockers

docker ps

Stop or kill running container

docker kill <container id from above command>
Continue reading “Docker Cheat sheet”

Send Salesforce Survey Without Code

Use Flow & Process builder to send customer satisfaction survey on case close

Salesforce Survey is available in Health Cloud & Financial Service Cloud otherwise its paid. Community Cloud is also required to use Survey.  If you need to practice Survey, create a 30 day trial org from this URL (mentioned in this trailhead module). One Survey can be created and used in Enterprise and Unlimited edition, so if you need only one survey then its free. In my case, I had to send same question to every customer on Case close , so it was free.

Prerequisite to use Salesforce Survey

Step 1 – Enable & create Community. Once community setup is done, we would need to activate it. Community can be created by any template. It can be blank as well, if it’s being created only for survey.

Step 2 – Enable Salesforce survey by navigating to Admin setup. You would need to select Community, which would be used by Survey to compute public unique link.

Salesforce - Enable Survey
Salesforce – Enable Survey

Continue reading “Send Salesforce Survey Without Code”

Build a Salesforce DX Plugin in 15 Min

My Dreamforce Session to create a Salesforce DX plugin in 15 minutes

Before deploying metadata in Sandbox of production, have you felt that how great it would be to generate configuration workbook ? Or compare sandboxes for difference ? Or check if fields are used on any page layouts or not ? Dear reader, you are in need of custom Salesforce DX plugin.

You heard it right, Salesforce DX allows custom plugin development. So now question is, how do you connect to Salesforce Org ? Do you need to know about OAuth or Single Sign On (SSO) ?

Complete source code is available on my Github repository here. Continue reading “Build a Salesforce DX Plugin in 15 Min”

Read Query Parameter in Lightning Component

Launch Lightning Component using formula field and also read query parameter in Salesforce Lightning Component

Before Summer 18, to read parameter in Lightning Component, we had to wrap Lightning Component in Lightning Application. After Summer 18, it has changed for good.

In this blog post we would create a formula field to launch Lightning Component (yes, you read it right). And then we would read URL parameter in Lightning Component using pageReference provided by interface lightning:isUrlAddressable.

Create a formula field on Account to launch Lightning Component and read its parameter. Continue reading “Read Query Parameter in Lightning Component”

Summary of Attachment, Document, Content Library and Files in Salesforce

Comparing between Attachment, Document, Content Library and Files in Salesforce

Summary :

  • Files is new way to store file in Salesforce
  • Content from external file service like Google, Box appears in Files
  • Files from Content Library displayed in file
  • CRM Content Library cannot be created in Lightning experience yet
  • Attachment and Files are two different objects, so two different related lists.
  • Attachment can be viewed in Lightning in Notes & Attachment related list
  • Attachments cannot be created in Lightning Experience, we should not use Attachments in future
  • To migrate existing Attachment to Files, use this AppExchange from Salesforce Labs
  • Document tab is not available in Lightning Experience
  • Documents should be replaced by File
  • Files yet does not support being used as attachment in Email Templates. If you are using Document in Email template, then keep it in Document
  • CRM Content delivery not available in Lightning but File can be shared with external user using Link
  • External user can only view or download file but cannot edit or update
  • File supports versioning
  • File can be related with multiple records.
  • File supports granular level sharing. It would be shared with anyone who has access to parent record. If you want to share with broad audience, it can be shared on chatter.

Continue reading “Summary of Attachment, Document, Content Library and Files in Salesforce”