Thrilling story of Salesforce Technical Architect on a quest to solve application problems and avoid governor limit errors
This is a work of fiction. Names, characters, businesses, places, events and incidents are either the products of the author’s imagination or used in a fictitious manner. Any resemblance to actual persons, living or dead, or actual events is purely coincidental.
Ha ha ha joking.. its combination of many real stories of my previous projects and few readers might be from my team itself 😉 . Leave comment my brave team mates if you are able to co-relate !!!
I tried to summaries as much as possibilities about governor limit errors and way to get out of it. Most of scenario described below may not be the first choice of Technical Architects however because of many reasons like budget, resource skill, tools available and compliance, bad decision could be taken which causes ripple effect on Salesforce scalibility.
Before start, I would encourage readers to leave comment on post and let everyone know in this suspenseful story, did you catch governor limits and Solution already before its exposed ? In this blog post, answers are mostly in invisible/white font which would not be seen until you highlight it. Its for few readers who don’t want spoilers.
Let’s start a story. Continue reading “A Tale of Governor Limits and Solutions in Salesforce”
Using Salesforce DX to Export and Import records into regular Salesforce Instances without dependency on developer hub org
In today’s continuous integration solution built for Salesforce, if you need to load sample data into Salesforce then either we use command line dataloader or custom tool built to import export records.
With Salesforce DX, we can import and export records right from Salesforce DX. Again, if you are new to Salesforce DX, then first read this blog post to quickly understand what is Salesforce DX.
We don’t need Developer Hub or Scratch Orgs to use Salesforce DX for import and export. In this blog post, I have used my regular developer org for demo.
First step as always, to make sure if Salesforce DX CLI is connected to your Org or not ? If its not connected then use below command to connect and give alias which is easy to remember. Continue reading “Import and Export Records using Salesforce DX”
Using old project format from ANT Migration toolkit or Force.com IDE ( package.xml ) in Salesforce DX without enabling Developer Hub
If you have existing VCS which stores metadata information about your Salesforce instance in old format, dependent on package.xml and you want to use Salesforce DX then this blog post is for you. As you might already know, Salesforce DX does not need package.xml and can automatically detect changes in your Salesforce instance, therefore new Salesforce DX project format is different. In this blog post we will see, how Salesforce DX can be used without enabling Developer Hub and using Salesforce DX with normal Salesforce instances.
There are two solution to this problem
- Keep using old Project format and use Metadata API to retrieve and deploy
- Convert old project format to Salesforce DX project Format
Continue reading “Use Metadata API with Salesforce DX”
Difference between Continuous Integration vs. Continuous Delivery vs. Continuous Deployment
I have written many posts about Continuous Integrations and implemented many projects with capability of Continuous Delivery. However multiple times got into discussion on what exactly is difference between Continuous Integration, Continuous Delivery and Continuous Deployment. As SFDX is new way to develop and deploy changes in Salesforce, just thought to post a small post on basic difference between these terms.
Continuous Integration is automated build scripts to detect changes in Source Code Management (SCM) like Git. Once the change is detected, source code would be deployed to common dedicated build server (Sandbox) to make sure build is not failing and all test classes and integration tests are running fine. Continue reading “Continuous Integration vs. Continuous Delivery vs. Continuous Deployment”
Display chevron control or breadcrumb in Flow to show Salesforce flow screen navigation progress
Have your end user complained or wanted some more coolness from Flow ? Do they want to have a nice clickable graphical presentation at top of page showing their progress or page number ? Recently, I was having a discussion with my colleague on same requirement. User should be able to jump between pages and at the same time, pictorial status should be displayed. Can we do it in Flow ? Can we create a chevron control or breadcrumbs in Salesforce Flow. Answer is yes.
Winter 18 has lots of cool functionalities for flow and we should not be left behind in adopting flow as part of our solution, at last, its point and click instead of code.
I will take help of my previous article, which explains how images can be used in formula field from static resources. In our case, instead of formula, we will use Display Text component in Flow. For this post, you can upload this zip file as a static resource and use in Flow. This zip file contains total 6 images for three pages, active and inactive images. Continue reading “Create Breadcrumb Or Chevron Control in Salesforce Flow”
Video tutorial and Complete source code to use Salesforce JWT OAuth to authenticate Nodejs Application
JWT OAuth uses digital signature to authenticate external application with Salesforce. JWT can be used to request an OAuth access token from Salesforce when a client wants to use a previous authorization.
Complete Source code is available here.
How JWT OAuth works
- Developer creates a connected app and provides digital certificate in OAuth settings. You can refer this post to understand how openssl can be used to create digital certificate locally.
- We need to make sure this connected app is already pre – approved either by using WebServer, User Agent or any other flow. You can find this step in video recorded.
- We need to generate JWT token and sign it with certificate. This code snippet is available in this file in method getJWTSignedToken_nJWTLib(). I have used njwt module of Nodejs to create a JWT token. This is very useful website to validate and generate JWT token as per digital certificate.
- Next we need to send JWT request to token URL – https://login.salesforce.com/services/oauth2/token
- If JWT request is valid then Salesforce returns access_token , which can be used in subsequent requests to perform allowed operations in Salesforce via Nodejs application.
Continue reading “Using JWT Flow to Authenticate Nodejs application with Salesforce”
My favorite Salesforce Winter 18 features about Lightning, Flow, Platform Event , Shield and Salesforce DX
There are many cool features features in Winter 18, however I would be listing only my favorite top picks from 589 pages of release notes. Would suggest to through this post to understand Sandbox readiness dates for Winter 18.
You can check materials of this meetup as well organized by Amit, where I shared my favorite Winter 18 feature with sample code.
New Lightning Base Components
Lightning Base components are out of the box component created with Salesforce Lightning Design System CSS. If there are no Lightning Base components, You would need to use aura or HTML components and write custom CSS to make look and feel similar to Lightning Experience. Base component starts with lightning: namespace. There are many new Base components introduced like lightning:datatable , lightning:checkboxGroup , lightning:dualListbox , lightning:progressIndicator , lightning:progressBar, lightning:slider. Recently only I blogged about Read only Chevron Component with mountains of code. Even though we are using this component for last 6 months however If my project could have waited, then all I had to use is 5-6 lines of code using lightning:progressIndicator.
2. Component Library (Beta)
We can already see all standard and custom component information using https://<myDomain>.lightning.force.com/auradocs URL. However, as part of Winter 18 release, Salesforce came up with revamped website just like Lightning Design System to show code snippets on how to use Lightning Components. You can navigate to Component Library using https://<myDomain>.lightning.force.com/componentReference/suite.app URL.
3. Lightning Data Services (GA)
We are hearing about Lightning Data Services from almost last one year and finally its generally available for use. You can check this blog post on how to use it. Continue reading “Salesforce Winter 18 Release – My Favorite Features”
Use Apex code to auto assign Accounts on basis of Enterprise Territory Assignment rules
Using Territory Management in Salesforce, we can auto assign territories to Account and give access to users working in common region. When we create Account, Territory Assignment rules automatically runs. On Account update we have a checkbox on page layout allowing to run Territory rules. However, Lightning experience does not support Territory Assignment checkbox yet on page layouts.
Unfortunately, Apex also does not support Account Assignment using Territory rules. Only way left is to use Salesforce API. Question is, just to run Enterprise Territory Management rules, should we import WSDL and convert it to respective Apex classes ? There must be some better way.
Then I remembered this article which I wrote around 5 years back. Instead of importing WSDL into Salesforce and converting it to Apex classes, we can take help of SOAP UI to find the request format and using HttpRequest, we can simulate request. Continue reading “Enterprise Territory Management – Auto Account Assignment using Apex”
Chevron Component build in Lightning with Same look and feel as of Salesforce Path in read only mode
Salesforce Path is awesome feature, where you can display picklist value at top of record page and on click, it updates value in Salesforce database. However same solution does not fit in all scenario. Consider situation where picklist field is supposed to be changed by some other process or Integration. Now you don’t want anyone to change it from user interface. Even though you like Salesforce Path to show summary at top of page however it won’t be useful in above scenario.
Because of this, I created a Read Only Path Component in Lightning. I tried to keep same look and feel as of Standard Path component. This component will need only two inputs
- Record Id – It would be automatically passed if we use it using App Builder
- Field API Name – API name of picklist type of field
Now think about it. Only thing I got is Record Id. How would I know Object Name ? How would I know all picklist values for field name supplied ?
With the help of this post, I will get Object name on basis of record Id. And, with the help of this post, I will get Field Description. Hopefully you got it, I am talking about Dynamic Apex here 🙂 .
Continue reading “Salesforce Path – Read Only Lightning Component”
How to use lightningStylesheets attribute to render Visualforce in Lightning Experience Stylesheet
Reason I posted previous blog was to showcase life of Visualforce developer before and after Winter 18. If we want to use same Visualforce in classic and Lightning experience then we had to check theme of logged-in user in Visualforce and render page section accordingly.
However, not any more. With Winter 18, we have LightningStylesheet attribute available for apex:page tag. Below source code produces same output as of previous code, however no extra logic to detect and render page section as per logged in user theme. Continue reading “Winter 18 – Automatic Styling of Visualforce Pages in Lightning Experience”