October 29, 2021

Knowledge Tab missing in Salesforce Lightning


1. Go to Knowledge Settings in Setup.

2. Make sure "Enable Lightning Knowledge" check box is checked.

October 26, 2021

We couldn't display the conversation entries exception in Salesforce


To Access ConversationEntry entity, "Access Conversation Entries" profile Permission is mandatory.

October 24, 2021

Re-Usable lightning record update form using Lightning Web Component LWC in Salesforce

Sample Code:
HTML:
<template>
    <lightning-card>
        <lightning-record-form
            record-id={recordId}
            object-api-name={objectApiName}
            fields={fieldsList}
            mode="edit"
            onsubmit={handleSubmit}
            onsuccess={handleSuccess}>
        </lightning-record-form>
    </lightning-card>
</template>

JavaScript:
import { api, LightningElement } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';

export default class ReusableRecordUpdateForm extends LightningElement {

    @api recordId;
    @api objectApiName;
    @api fields;
    fieldsList;

    connectedCallback() {

        console.log( 'Record Id is ' + this.recordId );
        console.log( 'fields is ' + this.fields );
        this.fieldsList = this.fields.split( ';' );
        console.log( 'fieldsList is ' + JSON.stringify( this.fieldsList ) );

    }

    handleSubmit( event ) {

        event.preventDefault();
        const fields = event.detail.fields;
        console.log( 'Values are ' + JSON.stringify( fields ) );
        this.template.querySelector( 'lightning-record-form' ).submit( fields );

     }

    handleSuccess( event ) {

        const evt = new ShowToastEvent( {
            title: "Record Updated",
            message: "Record Updated Successfully!!!",
            variant: "success"
        } );
        this.dispatchEvent( evt );

    }

}

meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordPage">
            <property name="fields" type="String" label="Fields" description="Enter the fields separated by semicolon" required="true"/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>


Configuration and Output: 
 
Contact Page Configuration:
 

Account Page Configuration:
 

Contact Page Output:
 
 
Account Page Output:

October 23, 2021

How to reset lightning-record-edit-form and get also get record id in Salesforce?

Sample Code:
HTML:
<template>
    <lightning-card title="Lead Creation">
        <lightning-record-edit-form object-api-name="Lead" onsubmit={handleSubmit} onsuccess={handleSuccess}>
            <lightning-messages></lightning-messages>
            <lightning-input-field field-name="FirstName"></lightning-input-field>
            <lightning-input-field field-name="LastName"></lightning-input-field>
            <lightning-input-field field-name="Email"></lightning-input-field>
            <lightning-input-field field-name="Phone"></lightning-input-field>
            <lightning-input-field field-name="Company"></lightning-input-field>
            <lightning-button label="Create Lead" variant="brand" type="submit"></lightning-button>&nbsp;&nbsp;&nbsp;  
            <lightning-button label="Reset" variant="brand" onclick={handleReset}></lightning-button>     
        </lightning-record-edit-form>
    </lightning-card>
</template>

JavaScript:
import { LightningElement } from 'lwc';
import {ShowToastEvent} from 'lightning/platformShowToastEvent';

export default class LeadCreationTab extends LightningElement {

    handleSubmit( event ) {

        event.preventDefault();        
        let fields = event.detail.fields;
        console.log( 'Fields are ' + JSON.stringify( fields ) );
        this.template.querySelector( 'lightning-record-edit-form' ).submit( fields );

    }

    handleReset( event ) {

        const inputFields = this.template.querySelectorAll( 'lightning-input-field' );
        if ( inputFields ) {
            inputFields.forEach( field => {
                field.reset();
            } );
        }

    }

    handleSuccess( event ) {
        
        console.log( 'Record Id is ' + event.detail.id );
        this.dispatchEvent(
            new ShowToastEvent( {
                title: 'Lead Submission Result',
                message: 'Lead Submitted Successfully',
                variant: 'success',
                mode: 'sticky'
            } )
        );

    }

}

meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__Tab</target>
    </targets>
</LightningComponentBundle>


Output:

October 22, 2021

How to show a panel only after selection of value from another panel in Splunk?

Use Drilldown Editor:



Sample XML:
<form>
  <label>Sample Explore</label>
  <search id="Event_transcript_search">
    <query>PLEASE ENTER YOUR QUERY</query>
    <earliestTime>$earliest$</earliestTime>
    <latestTime>$latest$</latestTime>
  </search>
  <search id="Event_key_search">
    <query>
      PLEASE ENTER YOUR QUERY
    </query>
    <earliestTime>$earliest$</earliestTime>
    <latestTime>$latest$</latestTime>
  </search>
  <fieldset submitButton="true" autoRun="false">
    <input type="text" token="OrgId">
      <label>Org Id</label>
      <default></default>
    </input>
    <input type="text" token="sampleToken">
      <label>Sample</label>
      <default></default>
    </input>
    <input type="time">
      <label>Time Frame</label>
      <default>
        <earliest>-15m</earliest>
        <latest>now</latest>
      </default>
    </input>
  </fieldset>
  <row>
    <panel>
      <table>
        <title>Event Keys</title>
        <search base="Event_transcript_search">
          <query>PLEASE ENTER YOUR ADDITIONAL STATEMENTS IN THE QUERY</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">cell</option>
        <drilldown>
          <set token="EventKey">$click.value2$</set>
        </drilldown>

      </table>
    </panel>
  </row>
  <row>
    <panel depends="$EventKey$">
      <table>
        <title>Events - $EventKey$</title>
        <search base="Event_key_search">
          <query>PLEASE ENTER YOUR ADDITIONAL STATEMENTS IN THE QUERY</query>
          <earliest>-24h@h</earliest>
          <latest>now</latest>
        </search>
        <option name="drilldown">row</option>
      </table>
    </panel>
  </row>
</form>

In the above example, when a cell is clicked from that panel, it captures the value and stores it in EventKey toekn. Then, the next panel is displayed only after that. In the initial dashboard load, the panel won't be loaded as it depends on EventKey token.

October 21, 2021

Chat not loading when navigating in Salesforce Experience Cloud/Community Cloud

To ensure that chat sessions are continued across pages, place the Embedded Service component in your site's template footer. 
 
 

October 20, 2021

Iterate Multi Picklist in Flow without Apex in Salesforce

Sample Flow:
 
 
Variables:
listSelectedIndustries is a Collection Variable to hold list of selected industries to show it on the Selected Industries Screen.

currentVal is to get the first value from the selected multi picklist values.

updatedIndustriesSelection is to hold the remaining values from the selected multi picklist values after removing the first value.

AccountIndustryPicklistValues is Picklist Choice Set to get picklist values from Industry field.

listSelectedIndustriesInitially is used to hold the selected values from the Home Screen. As we iterate, the values will be removed one by one in Semi Colon Assignment.

Home Screen:
To select multi picklist values.

 
Initial Industries Assignment:
Assigns listSelectedIndustriesInitially variable with the selection from the Home Screen.


Iterate Industries Selection:
Contains Semi Colon Node:

Checks whether listSelectedIndustriesInitially contains semi colon ';'.

Doesn't Contains Semi Colon Node:
Default. listSelectedIndustriesInitially doesn't contains semi colon ';'.
 

Semi Colon Assignment:
Adds currentVal formula variable value to the listSelectedIndustries collection variable.
Assigns listSelectedIndustriesInitially with the updateIndustriesSelection formula variable value.
 

No Semi Colon Assignment:
Adds updateIndustriesSelection formula variable value to the listSelectedIndustries collection variable.
 
 
Selected Industries Screen:
Displays the listSelectedIndustries collection variable.

 
Output:
 
 

October 19, 2021

Polymorphic Field in SOQL Queries in Salesforce

For Task Object with What field:
Apex:

List < Task > listTasks =
[ SELECT Id, Subject,  
    TYPEOF What
    WHEN Opportunity THEN Name, Amount
    END
FROM Task
LIMIT 15 ];

for ( Task objTask : listTasks ) {

    System.debug( objTask.Subject );

    if ( objTask.What instanceof Opportunity ) {
    
        Opportunity objOpportunity = objTask.What;
        System.debug( objOpportunity.Name );
        System.debug( objOpportunity.Amount );
       
    }
    
}

SOQL:
SELECT WhatId FROM Task WHERE What.Type = 'Opportunity'

For Conversation Entry Object with Conversation field:
Apex:
List < ConversationEntry > listCEs =
[ SELECT Id, ActorName, ActorType, EntryType, Message,  
    TYPEOF Conversation
    WHEN MessagingSession THEN MessagingChannel.DeveloperName, PreviewDetails
    ELSE Name
    END
FROM ConversationEntry
LIMIT 15 ];

for ( ConversationEntry objCE : listCEs ) {

    if ( objCE.Conversation instanceof MessagingSession ) {
    
        MessagingSession objMS = objCE.Conversation;
        System.debug( objMS.MessagingChannel.DeveloperName );
        System.debug( objMS.PreviewDetails );
       
    }
    
}

SOQL:
SELECT MessagingChannel.DeveloperName, PreviewDetails
FROM MessagingSession
WHERE Id IN (
    SELECT ConversationId FROM ConversationEntry WHERE CreatedDate = LAST_N_DAYS:15
)


Reference Article:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_SOQL_polymorphic_relationships.htm

October 17, 2021

How to pass list of string from Flow to LWC in Salesforce?

1. Lightning Web Component is
HTML:
<template>
    Selected industries are
    <template for:each={Industries} for:item="ind">
        <p key={ind}>{ind}</p>
    </template>
</template>

JavaScript:
import { LightningElement, api } from 'lwc';

export default class TestFlowComponent extends LightningElement {

    @api Industries;

}

js-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__FlowScreen</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen">
            <property name="Industries" label="Industries" type="String[]" />
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>


2. Create the following Apex Class to parse Multipicklist selection to list of String.
 
public class MultipicklistParser {
    
    @InvocableMethod
    public static List < List < String > > parseMultipicklist( List < String > strInputs ) {
        
        if ( strInputs.size() > 0 ) {
            
            List < List < String > > selectedOptions = new List < List < String > >();
            List < String > listTemp = strInputs.get( 0 ).split( ';' );
            selectedOptions.add( listTemp );
            return selectedOptions;
            
        }
        
        return null;
        
    }
    
}

 
3. Create a Flow.


Flow Resources:
 

 Account Industry Picklist Choice Set:
 

 

 


Output:
 
 

How to show a to-do list on the case page in each stage in Salesforce?

1. Update the Case Status Field as needed.


2. Create a Support Process.


3. Create a Record Type.


4. Enable Path Settings and add the fields and Guidance for Success.
 
Output:
 
New Case Status:
 

 Assigned Case Status:
 

 Working Case Status:
 

 Closed Case Status:
 

GACKs in Salesforce

"An internal server error has occurred." is nothing but a GACK. Check the following article for more information:

Vote for the following idea for making GACKs public reference:

October 16, 2021

How to subscribe to Platform Event using Lightning Web Component in Salesforce?

HTML:
<template>
    <lightning-card title="EmpApi Example" icon-name="custom:custom14">
        <div class="slds-m-around_medium">
            <lightning-button variant="success" label="Subscribe" title="Subscribe"
                onclick={handleSubscribe} disabled={isSubscribeDisabled}
                class="slds-m-left_x-small"></lightning-button>
            <lightning-button variant="destructive" label="Unsubscribe" title="Unsubscribe"
                onclick={handleUnsubscribe} disabled={isUnsubscribeDisabled}
                class="slds-m-left_x-small"></lightning-button>
        </div>
        <lightning-datatable 
            key-field="ReplayId"
            data={listEvents}
            columns={columns}
            hide-checkbox-column="true">
        </lightning-datatable>  
    </lightning-card>
</template>

JavaScript:
import { LightningElement } from 'lwc';
import { subscribe, unsubscribe, onError } from 'lightning/empApi';

export default class SamplePlatformEventsListener extends LightningElement {

    channelName = '/event/Test__e';
    isSubscribeDisabled = false;
    isUnsubscribeDisabled = !this.isSubscribeDisabled;
    subscription = {};
    listEvents;
    columns = [   
        { label: 'Serial No', fieldName: 'SerialNo' }, 
        { label: 'Replay Id', fieldName: 'ReplayId' }, 
        { label: 'Schema', fieldName: 'Schema' }
    ];

    connectedCallback() {   

        this.registerErrorListener();      

    }

    handleSubscribe() {
        
        const messageCallback = ( response ) => {
            console.log( 'New message received: ', JSON.stringify( response ) );
            let val =  { 
                'SerialNo' : response.data.payload.Serial_No__c, 
                'Schema' : response.data.schema, 
                'ReplayId' : response.data.event.replayId
            };
            console.log( 'Val is ' + JSON.stringify( val ) );
            console.log( 'Events before assignment are ' + JSON.stringify( this.listEvents ) );
            
            if ( this.listEvents ) {
                this.listEvents = [ ...this.listEvents,  val ];
            } else {
                this.listEvents = [ val ];
            }

            console.log( 'Events after assignment are ' + JSON.stringify( this.listEvents ) );
        };

        subscribe( this.channelName, -1, messageCallback ).then( response => {
            console.log( 'Subscription request sent to: ', JSON.stringify( response.channel ) );
            this.subscription = response;
            this.toggleSubscribeButton( true );
        });

    }

    handleUnsubscribe() {

        this.toggleSubscribeButton( false );

        unsubscribe( this.subscription, response => {
            console.log( 'unsubscribe() response: ', JSON.stringify( response ) );
        });

    }

    toggleSubscribeButton( enableSubscribe ) {

        this.isSubscribeDisabled = enableSubscribe;
        this.isUnsubscribeDisabled = !enableSubscribe;

    }

    registerErrorListener() {

        onError( error => {
            console.log( 'Received error from server: ', JSON.stringify( error ) );
        });

    }

}

meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__Tab</target>
    </targets>
</LightningComponentBundle>

Output:


October 15, 2021

"Unexpected close tag" Exception in Splunk Dashboard

This error is due to usage of < or > symbols. Do not use < or > symbols. Use &lt; and &gt; instead.

Example:
rex field=_raw "errorCode: (?<error_code>\d+)"

The above usage in the query will throw an error due to usage of < and > symbols. See the following resolution to resolve this issue.
rex field=_raw "errorCode: (?&lt;error_code&gt;\d+)"

October 14, 2021

Chatter compact is looking different in other objects Lightning Record Pages when compared to Case, Lead and Social Post object in Salesforce

The Case, Lead and Social Post objects uses the Compact Feed. Other objects doesn't use Compact Feed.
Please check the following article for reference.

Case, Lead, and Social post objects are supported to use the Compact Feed view in Lightning. 
 
Lead Chatter Component(Compact Feed):


Account Chatter Component(Non-Compact Feed):


Opportunity Chatter Component(Non-Compact Feed):


Case Chatter Component(Compact Feed):
 

Spell Check not working in Email compose in Salesforce after Winter '22 release

This is expected. Please check the following article
 
Press the CTRL or CMD key while right clicking to resolve the issue. 


LastViewedDate in Salesforce

Note:
This field is not available in KnowledgeArticle entity.
 
LastViewedDate is a date time field.

To update this when SOQL retrieve the field, use FOR VIEW Clause.
 
Sample SOQL:
SELECT Name, CreatedDate, LastModifiedDate, LastViewedDate FROM Account WHERE Id = '0015f000007xBkYAAU'

Output:
 


How to report on an object and it's related Feeds(Chatter Posts) in Salesforce?

1. Create a Custom Report type with Account and it's related Feeds for example.


2. Create a Report using the above Custom Report Type.


October 11, 2021

"Your query request was running for too long" exception in Salesforce

Your query request was running for too long
[sf: QUERY_TIMEOUT]. Reason [QUERY_TIMEOUT: Your query request was running for too long.]

If the query runs more than 2 mins(120 seconds), the query times out and throw the exception.

To avoid long execution times, non-selective SOQL queries may be terminated by the system.
https://help.salesforce.com/s/articleView?id=000325247&type=1

Maximum SOQL query run time before Salesforce cancels the transaction is 120 seconds(2 minutes). Check the following reference article.
https://developer.salesforce.com/docs/atlas.en-us.232.0.salesforce_app_limits_cheatsheet.meta/salesforce_app_limits_cheatsheet/salesforce_app_limits_platform_apexgov.htm

Use "SOQL_EXECUTE_BEGIN" in the Debug Logs. Find the start time and the time of the exception. If it is 120 seconds, then optimize the query.

Make SOQL selective to resolve this issue.
https://help.salesforce.com/s/articleView?id=000325257&type=1

October 10, 2021

Missed Chats in Salesforce

Check the following article for possible reasons.

Possible solutions to avoid
1. Use the Omni-Supervisor tab to find the agents Availability and Queue capacity and usage.
2. Increase the Queue capacity on the Chat Button(Queue Size Per Agent or Overall Queue Size).
3. Increase the number of agents.
4. Use Push Time-Out to assign the Chat to other available agents when the agent is not accepting the Chats.
5. Use Einstein Bot to handle the Chat and route it to the Agent when necessary. 

Vote for the following idea which can allow queuing Chats when Agents are away.

October 8, 2021

October 5, 2021

Mass Queue or Public Group Assignment using Lightning Web Component LWC in Salesforce

Apex Class:
public with sharing class PublicGroupOrQueueAssignmentController {

    @AuraEnabled( cacheable=false )
    public static UserWrapper fetchGroupAssignments( String strGroupId ) {

        UserWrapper objUW = new UserWrapper();
        Set < String > setAssignedUserIds = new Set < String >();
        List < UserOptionWrapper > allUsers = new List < UserOptionWrapper >();
        
        for ( GroupMember objGM : [ SELECT Id, UserOrGroupId FROM GroupMember WHERE GroupId =: strGroupId ] ) {
            
            String strUserOrGroupId = String.valueOf( objGM.UserOrGroupId );

            if ( strUserOrGroupId.startsWith( '005' ) ) {

                setAssignedUserIds.add( objGM.UserOrGroupId );

            }
        
        }
        
        for ( User objUser : [ SELECT Id, Name FROM User WHERE IsActive = true ] ) {
        
            UserOptionWrapper objUOW = new UserOptionWrapper();
            objUOW.label = objUser.Name;
            objUOW.value = objUser.Id;
            allUsers.add( objUOW );
        
        }
        
        objUW.availableUsers = allUsers;
        objUW.selectedUsers = new List < String >();
        
        if ( setAssignedUserIds.size() > 0 )
            objUW.selectedUsers.addAll( setAssignedUserIds );
        
        return objUW;

    }

    @AuraEnabled
    public static String addRemoveUsers( String strGroupId, List < String > selectedUsers, List < String > updatedUsers ) {
    
        List < GroupMember > listGroupMembersForInsert = new List < GroupMember >();
        Set < String > setUserIds = new Set < String >();
    
        try {
        
            Set < String > setSelectedUsers = new Set < String >();
            Set < String > setUpdatedUsers = new Set < String >();
            setSelectedUsers.addAll( selectedUsers );
            setUpdatedUsers.addAll( updatedUsers );
            
            for ( String strUserId : updatedUsers ) {
            
                if ( !setSelectedUsers.contains( strUserId ) ) {
                    
                    GroupMember objGM = new GroupMember();
                    objGM.UserOrGroupId = strUserId;
                    objGM.GroupId = strGroupId;
                    listGroupMembersForInsert.add( objGM );
                    
                }
            
            }
            
            for ( String strUserId : setSelectedUsers ) {
            
                if ( !updatedUsers.contains( strUserId ) ) {
                    
                    setUserIds.add( strUserId );
                    
                }
            
            }

            
            
            if ( setUserIds.size() > 0 ) {
                
                delete [ SELECT Id FROM GroupMember WHERE UserOrGroupId IN: setUserIds AND GroupId =: strGroupId ];

            }
            
            if ( listGroupMembersForInsert.size() > 0 ) {
            
                insert listGroupMembersForInsert;
                
            }

            return 'Successful';
            
        
        } catch ( Exception e ) {
        
            throw new AuraHandledException( e.getMessage() );
            
        }
    
    }
    
    public class UserWrapper {

        @AuraEnabled
        public List < UserOptionWrapper > availableUsers;
        @AuraEnabled
        public List < String > selectedUsers;

    }

    public class UserOptionWrapper {

        @AuraEnabled
        public String value;
        @AuraEnabled
        public String label;

    }

}


HTML:

<template>
    <div class="slds-box slds-theme--default">
        <lightning-input
            type="text"
            label="Enter the Queue or Public Group Id"
            onchange={handleChane}>
        </lightning-input>
        <br/>
        <lightning-button
            variant="brand"
            label="Fetch Details"
            onclick={fetchGropus}
            class="slds-m-left_x-small"
            disabled={showBool}>
        </lightning-button>
        <template if:true={showBool}>
            <lightning-dual-listbox
                label="Select/Remove User(s)"
                source-label="Available User(s)"
                selected-label="Selected User(s)"
                options={availableUsers}
                value={selectedUsers}
                onchange={handleUserChange}
                class="slds-m-around_medium">
            </lightning-dual-listbox>
            <lightning-button
                variant="brand"
                label="Save"
                onclick={saveChanges}
                disabled={disableBool}>
            </lightning-button>
        </template>
    </div>
</template>

JavaScript:
import { LightningElement } from 'lwc';
import fetchGroupAssignments from '@salesforce/apex/PublicGroupOrQueueAssignmentController.fetchGroupAssignments';
import addRemoveUsers from '@salesforce/apex/PublicGroupOrQueueAssignmentController.addRemoveUsers';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { refreshApex } from '@salesforce/apex';

export default class PublicGroupOrQueueAssignment extends LightningElement {
    
    publicGroupOrQueueId;
    availableUsers;
    selectedUsers;
    updatedUsers;
    showBool = false;
    disableBool = false;    

    handleChane( event ) {

        this.publicGroupOrQueueId = event.target.value;

    }

    fetchGropus() {

        console.log( 'Public Group or Queue Id is ' + this.publicGroupOrQueueId );
        fetchGroupAssignments( { strGroupId : this.publicGroupOrQueueId } )
        .then( data => {

            console.log( 'Records are ' + JSON.stringify( data ) );
            this.availableUsers = data.availableUsers;
            this.selectedUsers = data.selectedUsers;
            this.showBool = true;

        })
        .catch( error => {

            this.dispatchEvent(
                new ShowToastEvent( {
                    title: 'Error!!',
                    message: 'Some error occured. Please reach out to your Salesforce Admin for help!',
                    variant: 'error',
                    mode: 'sticky'
                } ),
            );     

        } )
        
    }

    handleUserChange( event ) {

        const selectedOptionsList = event.detail.value;
        console.log( 'Selected Options are ' + JSON.stringify( selectedOptionsList ) );
        this.updatedUsers = selectedOptionsList;
        console.log( 'Selected Users are ' + JSON.stringify( this.selectedUsers ) );
        console.log( 'Updated Users are ' + JSON.stringify( this.updatedUsers ) );

    }

    saveChanges() {
        
        let updatedBool = false;
        this.disableBool = true;

        if ( JSON.stringify( this.selectedUsers ) != JSON.stringify( this.updatedUsers ) ) {

            updatedBool = true;

        }

        if ( updatedBool == true ) {

            addRemoveUsers( { strGroupId : this.publicGroupOrQueueId,
                selectedUsers : this.selectedUsers, updatedUsers : this.updatedUsers } )
            .then( result => {

                console.log( 'Result ' + JSON.stringify( result ) );
                let message;
                let variant;

                if ( result === 'Successful' ) {

                    message = 'Successfully Processed!';
                    variant = 'success';

                } else {

                    message = 'Some error occured. Please reach out to your Salesforce Admin for help!';
                    variant = 'error';
                    
                }

                const toastEvent = new ShowToastEvent( {

                    title: 'Group(s) Assignment',
                    message: message,
                    variant: variant

                } );
                this.dispatchEvent( toastEvent );

            } )
            .catch( error => {

                console.log( 'Error ' + JSON.stringify( error ) );
                
            } );

        } else {

            alert( "No changes made!!!" );

        }

    }

}

JS-meta.xml:
<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>52.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__Tab</target>
    </targets>
</LightningComponentBundle>


Output: