Saturday, April 30, 2022

Salesforce LMS


Lightning Message Service (LMS) is the Salesforce technology of its kind that facilitates communication between Visualforce, Lightning Web Components, and Aura Components on a Salesforce Lightning Page.



 With the launch of LMS, Salesforce developers obtained a simple and seamless API for publishing messages throughout the Lightning Experience platform and subscribed to messages that originated from anywhere within Lightning Experience.

·         In LWC we can access Lightning Message Channel with the scoped module @salesforce/messageChannel.

·         In Visualforce, we can use global variable $MessageChannel.

·         In Aura, use lightning:messageChannel in your component

Create Lightning Message Channel

Currently we can create Lightning Message channel with Metadata API. You can create the same with the help of VsCode.

  You need to create one DX project then you need to place your message channel definition with the suffix .messageChannel-meta.xml in the force-app/main/default/messageChannels directory. like below folder structure.



 Sample Message-meta.xml

<?xml version="1.0" encoding="UTF-8"?>

<LightningMessageChannel xmlns="https://soap.sforce.com/2006/04/metadata">

    <masterLabel>Counter</masterLabel>

    <isExposed>True</isExposed>

    <lightningMessageFields>

        <fieldName>operator</fieldName>

    </lightningMessageFields>

    <lightningMessageFields>

        <fieldName>constant</fieldName>

    </lightningMessageFields>

</LightningMessageChannel>

Import a Message Channel:

Here’s how to import a Lightning message channel that a component can use to communicate via the Lightning Message Service.

// Syntax

import channelName from '@salesforce/messageChannel/channelReference';

// Syntax for resources in a managed package

import channelName from '@salesforce/messageChannel/namespace__channelReference';

// Example

import recordSelected from '@salesforce/messageChannel/Record_Selected__c';

channelName—An imported symbol that identifies the message channel.

channelReference—The API name of the message channel.

namespace—If the message channel is in a managed package, this value is the namespace of the managed package. If the message channel is not in a managed package, do not include a namespace.

Restrictions in LMS:

Here are several restrictions to the Lightning Message Service.

 >Under the following circumstances, you are unable to utilise LMS:

· Salesforce Mobile

· Communities

· AppExchange

Note:

LMS cannot be used to communicate with VF page contained in an iframe in Aura/LWC.

Examples of data that you can pass in a message include strings, numbers, booleans, and objects. A message cannot contain functions and symbols.

The lightning:messageChannel component is only available in Lightning Experience. 

Saturday, April 23, 2022

Custom settings vs Custom Metadata

 Custom settings are similar to custom objects and enable application developers to create custom sets of data, as well as create and associate custom data for an organization, profile, or specific user.

All custom settings data is exposed in the application cache, which enables efficient access without the cost of repeated queries to the database. This data can then be used by formula fields, validation rules, flows, Apex.

Custom metadata is customizable, deployable, packageable, and upgradeable application metadata.


Monday, April 11, 2022

Salesforce Source-driven Development

 In source-driven development, the source is organized into artifacts based on group features or customizations that are delivered together. Salesforce DX incorporates the artifact-based approach to organizing the source. 

There is the ability to shift the source of truth from the org to a version control system (VCS), along with the use of popular collaboration technologies including Git and other test-build automation tools.

A Salesforce DX project is a local directory structure of your metadata in source format. It lets you develop and test with Salesforce DX tooling.

Salesforce DX allows developers to use Git and source repositories when doing any sorts of development on Salesforce platform.

Scratch orgs are a central feature of Salesforce DX. The Scratch org is a source-driven and disposable deployment of Salesforce code and metadata.

Dev Hub allows you to create and manage scratch orgs. It is also essential create and manage second-generation packages, and use Einstein features.




ES12 new Features