Thursday, September 30, 2021

Queueable Apex

 First Batch:

global class BatchCalledThroughQueueable implements Database.Batchable<sObject>, Database.Stateful, Database.AllowsCallouts {

    global Database.QueryLocator start(Database.BatchableContext bc) {

        return Database.getQueryLocator(query);

    }

    global void execute(Database.BatchableContext bc, List<Lead> records){

    }

    global void finish(Database.BatchableContext bc){

    }

}

Second Queueable Class:

public class ExecuteBatchQueueableJob implements Queueable {

    public void execute(QueueableContext context) {

        try{

            BatchCalledThroughQueueable b = new BatchCalledThroughQueueable();

            Database.executeBatch(b, 200);

        }catch(Exception e){

            System.debug('@@@ Error Message : '+e.getMessage());

        }

    }

}

Third Batch:

global class BatchUpdate implements Database.Batchable<sObject>, Database.StatefulDatabase.AllowsCallouts {

        global Database.QueryLocator start(Database.BatchableContext bc) {

            Note: Calling Queueable job for calling the next batchfor chaining.

                System.enqueueJob(new ExecuteBatchQueueableJob());

            return Database.getQueryLocator(query);

        }

    global void execute(Database.BatchableContext bc, List<Contact> records){

    }

    global void finish(Database.BatchableContext bc){

    }

}

Wednesday, September 15, 2021

Instance Refresh and find hardcode instance like : NA65, CA38 in entire org

 


To find hardcode instances like NA65, CA38 in the entire org. 

Need to check below in components and follow reference links :

1. Static Resources

2. Custom Button or Link (Javascript)

3. Email Template 

4. Remote site settings

5. Visualforce pages

6. Custom lables





Reference links:

Lightning Experience Configuration Converter: https://lightning-configuration.salesforce.com/

https://www.infallibletechie.com/2018/09/things-to-consider-during-salesforce.html

Wednesday, September 8, 2021

LWC NavigationMixin - Redirect to parent record and LWC Headless action redirection

1. Reference link for LWC Headless action:

NOTE: This headless action is supported only on the standard record page. - Not worked for community's ref link:  

https://help.salesforce.com/s/articleView?language=en_US&type=5&release=232&id=release-notes.rn_lwc_quick_actions.htm


2. Navigate to LWC or Aura component with RecordId

handleAction(event) {
  var RecIdJSON.stringify(event.detail.row.Id);
    this[NavigationMixin.Navigate]({
        "type": "standard__component",
        "attributes": {
            "componentName": "c__TestForm" //if LWC component : c___test_form
        },
        state: {
            c__recordId: JSON.parse(RecId)
        }
    });
}
(OR)
    renderedCallback() {
        this.sfdcBaseURL = window.location.origin;
    }
 
    handleAction(event) {
var RecIdJSON.stringify(event.detail.row.Id);
       this[NavigationMixin.Navigate]({
                 "type": 'standard__webPage',
                 "attributes": {
                   "url": this.sfdcBaseURL+'/lightning/cmp/c__TestForm?c__recordId='+JSON.parse(RecId)
                 }
             });
    }


3. Sample Redirection to parent record:

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>
        <target>lightningCommunity__Page</target>
        <target>lightningCommunity__Default</target>
        <target>lightning__RecordAction</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__RecordAction">
            <actionType>ScreenAction</actionType>
        </targetConfig>
        <targetConfig targets="lightning__RecordPage">
            <objects>
                <object>Contact</object>
            </objects>
        </targetConfig>
        <targetConfig targets="lightningCommunity__Default">
            <property name="recordId" type="String" label="Record ID" 
description="Should be set to {!recordId}" default="{!recordId}"/>
        </targetConfig>
    </targetConfigs>
</LightningComponentBundle>

 Template:

<template>
    <div class="slds-clearfix">
        <div class="slds-float_right">
            <lightning-button label="Return to Roadmap" 
onclick={navigateToViewAccountPage}></lightning-button>
        </div>
    </div>
</template>


JS

  import { LightningElementapiwire } from 'lwc';
  import { getRecord } from 'lightning/uiRecordApi';
  import { NavigationMixin } from 'lightning/navigation';
  
  const FIELDS = ['Contact.Account.Name',
'Contact.Account.Id']; 

  export default class ReturnToRoadmapLWC extends NavigationMixin (LightningElement){
      @api recordId;  

      connectedCallback(){
        console.log('recordid========='+this.recordId);
      }

      //Wire the output of the out of the box method getRecord to the Contact object
      @wire(getRecord, { recordId: '$recordId'fields: FIELDS })
      Contact;
  
      //Navigate to Account record from Contact
      navigateToViewAccountPage(event) {
        var AccountName this.Contact.data.fields.Account.value.fields.Name.value;
        var AccountId this.Contact.data.fields.Account.value.fields.Id.value;            
          console.log('Contact Account name ========='AccountName);
          console.log('Contact Account ID ========='AccountId);
        this[NavigationMixin.Navigate]({
            type: 'standard__webPage',
            attributes: {
              url: '/'+AccountId
                //url: '/hello/s/testurl/'+AccountId+'/'+AccountName
            }
        });
      }
  }

CSS Styling

Styling: 1. Inline Styling: < div style = "font-size: 2rem;font-weight: 400;" > Good Evening </ div > 2. Usi...