Get Salesforce Org Limits Using Apex

Sample Code:

Map<String, System.OrgLimit> orgLimitMap = OrgLimits.getMap();
System.debug('OrgLimitMap-' + orgLimitMap);

for(String olName :orgLimitMap.keySet()) {
    System.OrgLimit orgLimit = orgLimitMap.get(olName);
    System.debug('Org Limit Name: ' + olName);
    System.debug('Org Limit Used:' + orgLimit.getValue());
    System.debug('Org Limit Available:' + orgLimit.getLimit());

Salesforce Apex TriggerOperation Enum

The System.TriggerOperation enum has the following values:


The new Trigger context variable Trigger.operationType will return System.TriggerOperation enum during trigger context.

If you combine this new context variable and the new Apex switch feature, trigger code becomes much easy to implement and understand.

Sample Switch and enum in Triggers:

trigger AccountTrigger on Account(before insert, after insert, before update, after update, before delete, after delete, after undelete) {
    switch on Trigger.operationType {
        when BEFORE_INSERT {
            //Invoke before insert trigger handler
            system.debug('Before Insert');
        when AFTER_INSERT {
            //Invoke after insert trigger handler
            system.debug('After Insert');
        when BEFORE_UPDATE {
            //Invoke before update trigger handler
            system.debug('Before Update');
        when AFTER_UPDATE {
            //Invoke after update trigger handler
            system.debug('After Update');
        when BEFORE_DELETE {
            //Invoke before delete trigger handler
            system.debug('Before Delete');
        when AFTER_DELETE {
            //Invoke after delete trigger handler
            system.debug('After Delete');
        when AFTER_UNDELETE {
            //Invoke after undelete trigger handler
            system.debug('After Undelete');

Create Custom Object From Spreadsheet In Salesforce

Lightning Object Creator is a new tool to create custom object from spreadsheets with just a few clicks.

Step 1:
Go to Setup | Object Manager | Select Custom Object from Spreadsheet

Step 2:
Upload spreadsheets from Microsoft Excel, Google Sheets, or comma-separated value (CSV) files.

Sample Spreadsheet:

Step 3:
After uploading the spreadsheet, Salesforce will automatically detect the fields. You can customize the Salesforce field name and field data type and you also can add field to page layout.

Step 4:
Define object properties and click on Finish button.

Created new custom object from Spreadsheet:

Get Current User Id in Lightning Web Component

To get current user id in Lightning Web Component, we need to import the "@salesforce/user/Id" Salesforce scoped module.


    <div class="slds-text-heading_large slds-text-align_center">
        User Id : {currentUserId}


import { LightningElement } from 'lwc';
import UserId from '@salesforce/user/Id';

export default class UserInformation extends LightningElement {
    currentUserId = UserId;


Salesforce Lightning Progress Bar With Conditional Theme

Lightning Component:

    <!--declare handler for render the JS method for Progress bar-->
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <!--declare attributes for progress bar value-->
    <aura:attribute name="progress" type="Integer" default="0"/>
    <div class="slds-m-around_xx-large">
        <div class="slds-progress-bar slds-progress-bar_large" aria-valuemin="0" aria-valuemax="100" aria-valuenow="{!v.progress}" role="progressbar">
            <span aura:id="prgBar" class="slds-progress-bar__value" style="{!'width:'+v.progress+'%'}">
                <span class="slds-assistive-text">Progress: {!v.progress}%</span>

Lightning JS Controller:

    //Specifying progress === 100 ? clearInterval(interval) : progress + 5 increases
    //the progress value by 5% and stops the animation when the progress reaches 100%
    //The progress bar is updated every 1000 milliseconds.
    doInit:  function (component, event, helper) {
        var interval = setInterval($A.getCallback(function () {
            var progress = component.get('v.progress');
            var prgBar = component.find("prgBar");
            if(progress >= 0){
            if(progress >= 25){
            if(progress >= 50){
            if(progress >= 75){
            component.set('v.progress', progress === 100 ? clearInterval(interval) : progress + 5);
        }), 1000);

Lightning Style:

.THIS .slds-is-low {
    background-color: green!important;
.THIS .slds-is-medium{
    background-color: yellow!important;
.THIS .slds-is-high{
    background-color: orange!important;
.THIS .slds-is-critical{
    background-color: red!important;