Posts

Enrich CDC and Event Filter

Image
Change Data Capture (CDC) are published by the platform and there is no specific limits around how many CDC would get published. Also, because of the same reason that platform is publishing these events what information would get passed is also pre-set and as a developer we did not any control over it. With new integration patterns following the event driven architecture there are quite of use cases where Salesforce CDC were not of help because of two primary reasons 1) Lack of ability to add information being passed in CDC 2) Processing overheads: Solution had to process lots of events which were not intended for it. Enrich fields and event filtering has now been introduced to rescue. On top of it also allows you to subscribe to single channel and listen to CDC from multiple objects or custom platform events. Enrichment is available only for CDC.  Filtering is available for CDC as well as custom platform events. Important thing to note is event filtering or CDC enrichment is supported

Client Credential Flow

Image
Client Credentials Flow is simple and easy authentication mechanism which Salesforce has newly introduced in Spring 23. This flow comes handy when you want to connect your app to Salesforce APIs outside the context of any particular user What does the Client Credential Flow brings to the table? - Consumer key and secret becomes the client credentials - Eliminates the need for explicit user credential sharing - More secure alternative to the OAuth 2.0 username password flow How client credential flow is more secure and easy to maintain than username password flow? There are two primary reasons which makes the client credential flow more secure 1. To get the access token, explicit user credentials are not required thus, encapsulates the user context 2. Client Id and Client Secret are comparatively long and random As the explicit user context is not known to third party application thus, it makes the integration dynamic and easy to maintain. Suppose, we have an integration which use us

Alternative to SFDX: Retrieve Source in Manifest from Org

Image
In majority cases, while creating project in VS Code, one follows the 3 steps; create project using manifest, authorize org and retrieve source in manifest from org. As manifest is the file, that might change from org to org, its a general practice to create a manifest or package.xml file with commonly retrieved metadata items like apex classes, lightning web components and so on. However, as the package.xml file becomes bigger in size (not specifically to certain number of lines) the SFDX command, retrieve source in manifest from org might or might not work (without any error). If the command is explicitly ran from terminal, it shows internal error with error code. Common workarounds like, restarting VS Code or updating Salesforce CLI would not help in this situation. This becomes a bottle neck.  Fortunately there are ways to retrieve the metadata, lets see the options we have. Option 1: Reduce the number of lines in package.xml This is

Dynamic Interactions on Lightning App Page

Image
Salesforce provides multiple ways to communicate between components which are not related to each other. E.g. pubsub module  or Lightning Message Service . For the components which are related to each other, one can use public properties of component in addition pubsub module or Lightning Message Service. However, it was not possible to use the public properties with unelated components on lightning app page. Recently, Salesforce has introduced dynamic interactions which lets you use public properties of components with unrelated components with some manual configurations. Lets understand how dynamic interactions can be used in lightning app page. NOTE: Dynamic Interactions are supported only on lightning app pages with limited activity between components What it takes to use dynamic interactions? A components which defines the event schema and publish the event, a component with public properties and few configurations on lightning app page. Lets

CSS Variables in LWC

Few developer like me who do not have UI/UX sight, writing and maintaining CSS takes time. Thus, few techniques like creating libraries for CSS files, comes very handy. With Summer 20 release, CSS library components can be created in LWC and can be used by importing library component in .js file and CSS file in .css file. Library component becomes the one place to change the application styling. However, some attributes values would be repeated all over the library component. Thus, making changes to application styling, one has to find and update such values. Thanks to advanced CSS and LWC for support of the standard web components, which lets developer define the custom properties or variables. Lets dive in how we can use CSS variables. Where to declare variables in LWC CSS file? The selector given to the ruleset defines the scope that the custom property/variables can be used. :root is the most common global. However, :root is not available in LWC.

Local credential store

Image
Storing Salesforce org credentials locally and using them without having to manually type in, had been a challenge for developers. Using browser extensions can lead to security compromise and thus are not allowed by organizations, using URLs with credentials as query string was the savior. However, from Spring 22 release, Salesforce has disabled this ability. Bookmarklets: Bookmarklets are essentially a psuedo javascript scripts which we can run on click of bookmark. This script can autofill credentials and enact button click thus, can be used as replacements for using usernames and passwords as HTTP URL query string parameters. Bookmarklets can be locally stored. Also these can be exported with bookmark html file. How to create bookmarklet? javascript pseudo selector should be used before IIFE function. IIFE is immediately invoked function expression. Let's take a look at example: javascript:(() => { document.getElementById("username").value="test@test.com.sandb

Redirect user to Salesforce UI using Session Ids

Recently, I was working on interesting requirement where user had to be redirected to Salesforce application with session id. Sharing the details about how we can achieve this in Salesforce. Once the user enters his credentials on Salesforce login screen, on successful authentication Salesforce internally redirects user to default landing page using frontdoor.jsp . Salesforce has leveraged this feature for developers. For using frontdoor.jsp , couple of things are required, first is server url (it can be login.salesforce.com or test.salesforce.com or custom domain url) and second is active session id < server url >/ secur / frontdoor . jsp ? sid =< session_id > Eg. https: //login.salesforce.com/secur/frontdoor.jsp?sid=00D0K0000024Spm!ARkAQLF3GhBYzftBP42x6oviafHgbc3Op_cfbylGDPbTAbE3cMeVKSOoZIa3U5Zi51VPMSEKTC3oVcX