Top Salesforce blog – Listed by Feedspot

It gives us immense pleasure to inform that salesforcebuddy.com was selected by Feedspot as one of the top 75 blogs in Salesforce technology.

Feedspot has a panel of technology experts who review and assess the blogs and rank them on various parameters. You can view their website at URL mentioned above. It surely is an encouragement and I look forward to serving the salesforce community even further going forward.

Thanks for reading!!

Dave

Permanent link to this article: https://salesforcebuddy.com/2020/04/top-salesforce-blog-listed-by-feedspot/

LWC – Hello World

So far, we have been building lightning components using aura components. There is another new way or approach to build lightning components and we will see a very basic “Hello World” example today. I will post more articles on complex LWC in subsequent weeks

Lightning Web Components uses core web components standards and provides only what’s necessary to perform well in browsers supported by Salesforce. You can create a lwc in VS Code project

Essentially, there are 3 main elements to create a simple lwc

  • HTML provides the structure of component.
  • JavaScript (JS) defines the core business logic and event handling.
  • CSS gives look and feel, and animation for the component.

HTML

The template tag is a fundamental building block of a component’s HTML. It allows you to store pieces of HTML.

<template>

    <input value={message}></input>

</template>

JavaScript

import { LightningElement } from ‘lwc’;
export default class App extends LightningElement {
message = ‘Hello World, from LWC’;
}

CSS

input {

   color: red;

}

Project Structure in IDE
Screen Output

Permanent link to this article: https://salesforcebuddy.com/2020/04/lwc-hello-world/

Delete Record using Flow

There will be times when you may need to delete a record from Process Builder flows.

Business Problem

We have a shopping cart which was created by the user. For any cart ( and cart items) which are not checked out, they will be lying in the system and will not be easy to identify to cleanup later.

  1. The business requirement is to send an email to the Cart Owner after 1 day asking them for any help to complete their process
  2. If the cart is not checked out after 7 days, it needs to be removed.

For the solutionining, Process Builder flow is an easy option to look, however, flows does not let you delete records. You may want to write an apex class and have it scheduled but that is not a preferred option. We should stay with configurations as much as possible

Call an Apex Method from a Process

We can write an apex class with an invocable method to do just the deletion part. The apex class/method itself can be invoked from the flow, so this is a hybrid approach with more configuration and less code

public class DeleteOldCarts
{
    @InvocableMethod
    public static void DeleteCart(List<String> cartIdList)
    {
       List<RG_Cart__c> cartList =[select id from RG_Cart__c where id in :cartIdList];
        delete cartList;
   }
}

The complete flow for this user requirement is shown below.

  1. Whenever 1 day has passed from the cart creation, we send out an email alert
  2. Whenever 7 days has passed since the cart creation and it is still in pending stage, we delete the cart

Permanent link to this article: https://salesforcebuddy.com/2020/04/delete-record-from-flow/