Author Archives: Biswajeet

About Biswajeet

Biswajeet is my Name, Success is my Aim and Challenge is my Game. Risk & Riding is my Passion and Hard Work is my Occupation. Love is my Friend, Perfection is my Habit and Smartness is my Style. Smiling is my Hobby, Politeness is my Policy and Confidence is my Power.

Create FeedComment Record in Apex Test Class

Sample Code:

//Parent Record
Account acc = new Account(Name = 'Test Account');
insert acc;

//Create Related Feed Item Record
FeedItem fi = new FeedItem(ParentId = acc.Id, Body = 'Test Body');
insert fi;

//Create Feed Comment Record
FeedComment fc = new FeedComment(FeedItemId = fi.Id, CommentBody = 'Test Comment');
insert fc;

//Get Feed Comment Record
FeedComment objFC = [Select Id, CommentBody, FeedItemId, ParentId FROM FeedComment LIMIT 1];

//Check Feed Comment Parent Id
System.assertEquals(objFC.ParentId, acc.Id);

LWC Multi Step Wizard

Biswajeet   September 29, 2020   No Comments on LWC Multi Step Wizard


    <lightning-progress-indicator current-step={currentStep} type="base" variant="base">
        <lightning-progress-step label="Step 1" value="1" onclick={handleOnStepClick}></lightning-progress-step>
        <lightning-progress-step label="Step 2" value="2" onclick={handleOnStepClick}></lightning-progress-step>
        <lightning-progress-step label="Step 3" value="3" onclick={handleOnStepClick}></lightning-progress-step>
    <template if:true={isStepOne}>
            Step 1
    <template if:true={isStepTwo}>
            Step 2
    <template if:true={isStepThree}>
            Step 3
    <template if:true={isEnablePrev}>
        <lightning-button variant="base" label="Back" onclick={handlePrev}></lightning-button>
    <template if:true={isEnableNext}>
        <lightning-button label="Next" variant="brand" onclick={handleNext}></lightning-button>
    <template if:true={isEnableFinish}>
        <lightning-button label="Finish" variant="brand" onclick={handleFinish}></lightning-button>


import { LightningElement, track} from 'lwc';

export default class LWCWizard extends LightningElement {

    @track currentStep = '1';

    handleOnStepClick(event) {
        this.currentStep =;

    get isStepOne() {
        return this.currentStep === "1";

    get isStepTwo() {
        return this.currentStep === "2";

    get isStepThree() {
        return this.currentStep === "3";

    get isEnableNext() {
        return this.currentStep != "3";

    get isEnablePrev() {
        return this.currentStep != "1";

    get isEnableFinish() {
        return this.currentStep === "3";

        if(this.currentStep == "1"){
            this.currentStep = "2";
        else if(this.currentStep = "2"){
            this.currentStep = "3";

        if(this.currentStep == "3"){
            this.currentStep = "2";
        else if(this.currentStep = "2"){
            this.currentStep = "1";



To create “base” style progress indicator you have need to add type="base" attribute in your lightning-progress-indicator tag in lightning component.

To create “path” style progress indicator you have need to add type="path" attribute in your lightning-progress-indicator tag in lightning component.

Check Current User has a Custom Permission in Salesforce Using Apex

we can use FeatureManagement.checkPermission method, to determine which users have access to a specific custom permission.

Sample Code:

Boolean hasCustomPermission = FeatureManagement.checkPermission('YOUR_CUSTOM_PERMISSION_API_NAME');

Converting DateTime to Date in Salesforce

Solution 1: Create a date newInstance() and pass the Year, Month and Day from the dateTime.

DateTime dt =;
Date d = Date.newInstance(dt.year(), dt.month(),;
System.debug('Print Date:' + d);

Solution 2: Get date from the DateTime using Date() method.

DateTime dt =
Date d =;
System.debug('Print Date:' + d);

Google reCAPTCHA in Lightning Component

Configure the Google reCAPTCHA and get the Site Key & Secret Key:

  • Login to Google reCAPTCHA
  • Register a new site
  • Add Label e.g.
  • Select reCAPTCHA type “reCAPTCHA v2”
  • Select “I’m not a robot” Checkbox option.
  • Add a domain e.g.
  • Accept the reCAPTCHA Terms of Service
  • Submit and get the Site Key & Secret Key

Create a VF page to configure Google reCAPTCHA in it and we have to embed the VF page in our lightning component.

GoogleReCaptcha VF Page:

<apex:page sidebar="false" showHeader="false" standardStylesheets="false" cache="false" id="pg" applyBodyTag="false" applyHtmlTag="false">
            <script src='' async='' defer=''/>
            <script type='text/javascript'>
                var verifyCallback = function(response){
                    parent.postMessage('VALID', '');
            var onloadCallback = function() {
                grecaptcha.render('reCAPTCHAWidget', {
                    'sitekey' : 'ADD_YOUR_GOOGLE_RECAPTCHA_SITE_KEY', 
                    'callback' : verifyCallback
            <div id="reCAPTCHAWidget"></div>

Embed the above created VF page in our lightning component to display Google reCAPTCHA.
Lightning Component:

<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable,forceCommunity:availableForAllPageTypes" access="global">
    <aura:attribute name="isDisable" type="Boolean" default="true"/>
    <aura:attribute name="firstName" type="String"/>
    <aura:attribute name="lastName" type="String"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <div class="slds-m-around--xxx-large slds-align_absolute-center" style="width:70%;">
        <fieldset class="slds-box slds-align_absolute-center" >
            <legend id="newform" class="slds-text-heading--small login-heading">
            <lightning:input name="fName" label="First Name" value="{!v.firstName}"/>
            <lightning:input name="lName" label="Last Name"  value="{!v.lastName}"/>
            <iframe src="/apex/GoogleReCaptcha" scrolling="no" frameborder="0" width="100%" allowtransparency="true"></iframe>
            <div class="slds-align_absolute-center">
                <lightning:button onclick="{!c.handleSubmit}" disabled="{!v.isDisable}" variant="brand" name="btnSubmit" label="Submit"   />

Lightning JS Controller:

    doInit : function(component, event, helper) {
        var vfURL = '';
        window.addEventListener('message', function(event){
            if(event.origin !== vfURL){
            if( === 'VALID'){
                component.set('v.isDisable', false); 
        }, false);
    handleSubmit : function(component, event, helper) {