Salesforce : Consultant Tip's 2024



Salesforce : Consultant Tip's 2024

Many people are requesting to show all the tips as a web page so they can easily checkout for your usages so I'm creating a blogger for my followers and friends. :


  • Tip of the week # 162 : Deploy Metadata Using REST API.

    Description : SDeploy using the deployRequest REST resource to initiate a request that handles all operations for the deployment.
    
        
    EndPoint : https://host/services/data/vXX.0/metadata/deployRequest
    Format : JSON
    Method : POST
    Authorization: Bearer token 
    
    
    
    You can deploy or retrieve up to 10,000 files at once. AppExchange packages use different limits: They can contain up to 35,000 files. The maximum size of the deployed or retrieved .zip file is 39 MB. If the files are uncompressed in an unzipped folder, the size limit is 400 MB.
  • Tip of the week # 161 : Styling Hooks for LWC.

    Description : Styling hooks use CSS custom properties which make it easy to customize component styling and express your brand, especially when working with web components and shadow DOM.
    Snapshot of Code : For LWC Component (Create component with CSS file) : HTML :
    
        
    <template>
        <center>
        <div class="slds-m-top_small slds-m-bottom_medium">
            <lightning-card  title="SLDS Styling Hooks for CSS.">
                    <lightning-button class="button" variant="brand" label="Styling Hooks" title="custom"></lightning-button>
            </lightning-card>
        </div>
        </center>
    </template>
    
    
    
    
    CSS :
    
    
    lightning-button.button {
        --sds-c-button-brand-color-background: #bb00ff;
        --sds-c-button-text-color: #f4f7f9;
        --slds-c-button-brand-color-border: #bb00ff;
    }
    
    
    
    
    Note : Styling hooks are constructed using CSS custom properties. (also referred to as CSS variables or cascading variables.
  • Tip of the week # 160 : Create Util CSS class for LWC.

    For CSS Component (Create new LWC component with name importCSS and remove all component and Create CSS file in LWC) :
    importCSS.css
    
        
    .buttonShadow{
        box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 4px, rgba(0, 0, 0, 0.3) 0px 7px 13px -3px, rgba(0, 0, 0, 0.2) 0px -3px 0px inset;
    }
    .buttonBrand{
        background-color: #081567;
        border-color: #081567;
    }
    .buttonDestructive{
        background-color: #970b06;
        border-color: #970b06;
    }
    .buttonSuccess{
        background-color: #155a3c;
        border-color: #155a3c;
    }
    
    
    
    
    For LWC Component (Create component with CSS file) :
    HTML :
    
    
    <template>
        <div class="slds-m-top_small slds-m-bottom_medium">
            <lightning-card  title="Buttom with Custom CSS.">
                <button type="button" class="slds-button slds-button_destructive buttonBrand slds-m-left_x-small buttonShadow">Brand</button>
                <button type="button" class="slds-button slds-button_destructive buttonDestructive slds-m-left_x-small buttonShadow">Destructive</button>
                <button type="button" class="slds-button slds-button_destructive buttonSuccess slds-m-left_x-small buttonShadow">Success</button>
             </lightning-card>
      </div>
    </template>
    
    
    
    CSS :
    
    
    @import "c/importCSS";
    
    
    
    Note : CSS component just need CSS file only.
  • Tip of the week # 159 : Dataset property for getting from UI.

    HTML Template
    
        
    <template for:each={accountList} for:item="account"> 
    <div key={account.Id}> Name: {account.Name} flag: {account.flag} type: {account.Type} 
    <lightning-button label="Click" data-name={account.Id} onclick={handleClick}>
    </lightning-button> 
    </div> 
    </template> 
    
    
    
    JS
    
    handleClick(event){ console.log(event.target.dataset.name); }
    
    
    Note : for accessing dataset from LWC (UI component), you have to use data-(Property Name) then you are able to get via events.
  • Tip of the week # 158 : Field import in LWC and get value without Query.

    
    public class PickListOptionsController {
        @AuraEnabled        
        public static List getPickListOptionList(String objectName, String picklistFieldName){
            List picklistOptionList = new List();
            Schema.SObjectType convertToObj = Schema.getGlobalDescribe().get(objectName);
            Schema.DescribeSObjectResult res = convertToObj.getDescribe();
            Schema.DescribeFieldResult fieldResult = res.fields.getMap().get(picklistFieldName).getDescribe();
            List ple = fieldResult.getPicklistValues();
            for( Schema.PicklistEntry pickListVal : ple){
                picklistOptionList.add(pickListVal.getLabel());
            }     
            return picklistOptionList;
        }
    }
    
    
    Note : Dynamic import are referenced so if anyone tries to delete the field then it will show an error message and show in the reference list.

Happy Sharing...

Everyone has their own favorites, so please feel free to share with yours contacts and comments below for any type of help!

Comments

Popular posts from this blog

Salesforce LWC : Compact Layout on Hover

Salesforce LWC With Third Party JS : D3

Communications between Lightning Components : Salesforce