Monthly Archives

  • Clone With Related Records Feature

    What is Clone with Related Records Feature?

    The ClonewithRelated action adds every relatedrecord from the original object to the cloned object. An example would be a user that wants to create a new Opportunity using an existing one as the source.

    What is the difference between Clone and Clone With Related Records Feature?:

    Clone Feature enables us to clone or make copy of record which we have selected, but If we select Clone with Related, it will ask us to clone the record along with related records that you want to carry over to the new record.

    What are the steps to perform Clone with Related Records:

    There are various steps to perform Clone with Related Records follow as

     Step 1 -> Go to Setup -> Object Manager -> Select The Object -> Page Layout> Mobile And Lightning Action -> Drag The Clone With Related Button

    Step 2 –> After successfully performed step 1 ,we can see the button Clone With Related  on object’s record.We have taken opportunity for example

    Step 3  –> By the clicking on the button ,it will show all related list record and ask us to choose what related list record we want to clone and click Next button.

    Step 4  –> When we click Next button, it will take us to choose what changes we need to make in record.

    Example – We are cloning Opportunity with Opportunity related list.Soo the step 3 allow us to choose what related list of Opportunity we want and After clicking of  next button, it will allow us to choose what all changes we want in opportunity record

    Step 5 –> After completing all above steps, we can see that we have one record cloned from another record.

  • Assign Tasks to Queues

    This change applies to Lightning Experience in Essentials, Professional, Enterprise, Performance, Unlimited, and Developer editions.

    Let sales reps share their workload by setting up queues for tasks. Reps can assign tasks to their shared queues, and then individuals can take ownership of those tasks from the queue’s list view.

    When reps assign tasks to a queue, those tasks are available to members of the queue, which means everyone can pitch in to help. No more relying on one sales rep to do it all. Now others on the team can lend a hand without waiting for work to be delegated or reassigned.

    How to Setup Queues:-

    First, go to Setup then in Quick Find Box type Queues and then select Queues. From the Queues setup page, select New. Then, create a queue and select Task as the supported object and select users to whom you want to assign a Task.

  • Lightning Message Service

    Information :-

    Lightning Message Service (LMS) allow us to communicate between visualforce and Lightning component(Aura and Lightning web component both) on any lightning page.

    LMS API allow you to publish message throughout the lightning experience and subscribe the same message anywhere with in lightning page. It is similar to Aura Application Events to communication happens between components.

    Lightning Message Service is based on a new metadata type: Lightning Message Channels. We need to use Lightning Message Channel to access the Lightning Message Service API.

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

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

    3. In Aura, use lightning:messageChannel in your component

    When to use Lightning Message Service :-

    In Lightning Experience, if we want a Visualforce page to communicate with a Lightning web component then we have to implement a custom publish-subscribe solution because this is currently not possible with LWC Event. Now, we can use the Lightning Message Service API to handle this communication.

    Steps to create Lightning Message Service :-

    • Create a message channel called SampleMessageChannel__c using the Metadata API.
    • Create a Lightning web component called publisherComponent that publishes on SampleMessageChannel__c message channel.

    The publisherComponent code is :-

    // publisherComponent.js

    import { LightningElement, wire } from ‘lwc’;

    import { publish, MessageContext } from ‘lightning/messageService’;

    import SAMPLEMC from “@salesforce/messageChannel/SampleMessageChannel__c”;

    export default class PublisherComponent extends LightningElement {

     @wire(MessageContext)

       messageContext;

       handleClick() {

            const message = {

                recordId: “Any string”,

                recordData: {

                 value: “any data”

                }

            };

            publish(this.messageContext, SAMPLEMC, message);

        }

    }

    In HTML template file of component includes a Publish button that calls the handleClick() method. OnClick of that button it publishes the record data to SampleMessageChannel__c. The subscribing Visualforce page then receives that data.

    publisherComponent.html Code :-

    <template>

        <lightning-card title=”MyLwcPublisher” icon-name=”custom:custom14″>

            <div class=”slds-m-around_medium”>

                <p>MessageChannel: SampleMessageChannel</p>

                <br>

                <lightning-button label=”Publish” onclick={handleClick}></lightning-button>

            </div>

        </lightning-card>

    </template>

    Lightning web component Code :-

    <apex:page>

        <div>

            <p>Subscribe to SampleMessageChannel</p>

            <button onclick=”subscribeMC()”>Subscribe</button>

            <p>Unsubscribe from SampleMessageChannel</p>

            <button onclick=”unsubscribeMC()”>Unsubscribe</button>

            <br/>

            <br/>

            <p>Received message:</p>

            <textarea id=”MCMessageTextAreaId” rows=”10″                        style=”disabled:true;resize:none;width:100%;”/>

        </div>

        <script>

            // Load the MessageChannel token in a variable

            var SAMPLEMC = “{!$MessageChannel.SampleMessageChannel__c}”;

            var subscriptionToMC;

            function onMCPublished(message) {

                var textArea = document.querySelector(“#MCMessageTextAreaId”);

                textArea.innerHTML = message ? JSON.stringify(message, null, ‘\t’) : ‘no message payload’;

            }

            function subscribeMC() {

                if (!subscriptionToMC) {

                    subscriptionToMC = sforce.one.subscribe(SAMPLEMC, onMCPublished, {scope: “APPLICATION”});

                }

            }

            function unsubscribeMC() {

                if (subscriptionToMC) {

                    sforce.one.unsubscribe(subscriptionToMC);

                    subscriptionToMC = null;

                }

            }

        </script>

    </apex:page>