Monday, September 21, 2020

Display Google Map within a Flow using Lightning Web Components

Motivation behind this


Earlier I have written about the post on displaying Google maps either on Salesforce Community and through drag-and-drop functionality. From a long time, I want to experiment that on Flow and tried to achieve the same thing.

This way, we can extend the power of Lightning Web Components combining the configurable features of Flow.

Use Case


Business has a requirement to see the location of an Account in a Google Map, but only on a demand basis. Business doesn't want to see this map on Record Detail page every time. Rather, they want to view as and when required upon clicking on a button on Record Detail page and it will show as a pop up screen.

Developer wants to build this Google map component using Lightning Web Components which will be displayed as a pop up using Flow.

Expected Outcome




Clicking on Show Location quick action, the flow will be displayed as pop up screen to display the location.

Solution Approach


Salesforce provides lightning-map component which displays one or more locations. It inherits the styling from map of Lighting Design System. 

And, it is easier to display the component inside Flow, rather than using a separate pop-up component.

So, let's first prepare the component in LWC.

displayAccountMapInFlow.html

Simple page which holds lighting-map component.


<template>
    <lightning-map
        map-markers={mapMarkers}
        zoom-level={zoomLevel}>        
    </lightning-map>    
</template>

displayAccountMapInFlow.js

Few important points on the approach:
  • My earlier post talks about fetching the data using Apex classes. Here I have used ui*api Wire adapters. The benefits of using this is, we don't have a create separate Apex Class to fetch the record. Secondly, it recognizes access rights of the users meaning if the user doesn't have access to the field then error will return. If you are not sure about field access then you can use those fields as Optional.
  • We know that, we can get recordId using @api, but when the component is embed into flow then this recordId will not work. We need to pass recordId explicitly from Flow. This is tricky.
  • As this component can be reused to display in App page or record detail page so the recordId check has been done in connectedCallback method. 
Following way, you can check falsy values, no need to separately verify null or undefined.

this.recordId = (!!this.recordId) ? this.recordId: this.sfdcRecordId; 

Here is the way, through metadata config file.

<targetConfigs>
	<targetConfig targets="lightning__FlowScreen">
		<property name="sfdcRecordId" 
			type="string" 
			label="Pass record Id"
			description="Pass record Id"/>			   
	</targetConfig>
</targetConfigs> 

Entire .js as below


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Author: Santanu Boral
*/
import { LightningElement, api,track, wire } from 'lwc';
import { ShowToastEvent } from 'lightning/platformShowToastEvent';
import { getRecord } from 'lightning/uiRecordApi';

//define the field values to be retrieved
const FIELDS = ['Account.Name', 'Account.BillingStreet',
                'Account.BillingCity', 'Account.BillingState',
                'Account.BillingPostalCode', 'Account.BillingCountry'
                ];

export default class DisplayAccountMapInFlow extends LightningElement {
    @api recordId;  //if this component is used other than flow then it will be used
    @api sfdcRecordId; //this is passed from flow
    @api zoomLevel; //this is passed from flow
    
    account; //internal variable to store the account data
    mapMarkers = [];  //this is used on HTML for attribute value 
    
    //This method check the values passed into the component
    connectedCallback(){
        this.recordId = (!!this.recordId) ? this.recordId: this.sfdcRecordId;  
        this.zoomLevel = (!!this.zoomLevel) ? this.zoomLevel: 6;        
    }

    //fetch record details based on recordId
    @wire(getRecord, { recordId: '$recordId', fields: FIELDS })
    wiredRecord({ error,data }) {
        if (data) {
            this.account = data;
            //prepare marker to display on map
            this.mapMarkers = [
                {
                    location: {
                        Street: this.account.fields.BillingStreet.value,
                        City: this.account.fields.BillingCity.value, 
                        State: this.account.fields.BillingState.value,
                        PostalCode: this.account.fields.BillingPostalCode.value,                         
                        Country: this.account.fields.BillingCountry.value
                    },    
                    icon: 'custom:custom26',
                    title: this.account.fields.Name.value,
                }                                    
            ];
            
        }
        else if (error){
            let message = 'Unknown error';
            if (Array.isArray(error.body)) {
                message = error.body.map(e => e.message).join(', ');
            } else if (typeof error.body.message === 'string') {
                message = error.body.message;
            }
            this.dispatchEvent(
                new ShowToastEvent({
                    title: 'Error loading Account',
                    message,
                    variant: 'error',
                }),
            );
        }
    }
}

displayAccountMapInFlow.js-meta.xml

You can see the zoomLevel has been passed along with recordId from Flow.


<?xml version="1.0" encoding="UTF-8"?>
<LightningComponentBundle xmlns="http://soap.sforce.com/2006/04/metadata">
    <apiVersion>49.0</apiVersion>
    <isExposed>true</isExposed>
    <targets>
        <target>lightning__RecordPage</target>
        <target>lightning__AppPage</target>
        <target>lightning__FlowScreen</target>
    </targets>
    <targetConfigs>
        <targetConfig targets="lightning__FlowScreen">
            <property name="zoomLevel" 
                type="string" 
                label="Enter zoom level of map"
                description="Enter zoom level of map"/>   
            <property name="sfdcRecordId" 
                type="string" 
                label="Pass record Id"
                description="Pass record Id"/>                   
        </targetConfig>
    </targetConfigs>        
</LightningComponentBundle>

Development on Flow Side


Overall flow will look like as below:


First, create recordId variable to capture the recordId of the current record.


Next, create a variable with text datatype with a name varRecordId.

Now, assignment to be done as follows:


Finally, the form screen as below


You can see that zoom level is passed as 16 and record Id has been passed with {!varRecordId}

Now, let's call this flow through quick action and expose that in the page layout.

That's it!.

For testing purpose, go to a record detail page and clicking on Show Location quick action, the flow will be opened to display the component.

Hope it helps and thanks for reading.

References



Further Reading




Friday, September 4, 2020

Salesforce JavaScript Developer I Certification Cheat Sheet - 6 Pager

 Motivation behind this

After passing JavaScript Developer I certification, I thought of preparing this cheat sheet which is a bridge between the syllabus and level of questions and can provide proper guidance to effectively prepare for this exam.

I didn't find this type of material during my preparation which motivates me to come up such a 6 pager cheat sheet which covers almost all important points and sections. This document mainly focuses on multiple choice exam. I have provided all the references at each section.

This will definitely help trailblazers to prepare and pass this exam.

To download entire cheat sheet in pdf version, scroll through at the end of the blog.

Here is each page will look like:

Page 1



Page 2


Page 3


Page 4

Page 5


Final Page



Download entire cheat sheet: Salesforce JavaScript Developer I Cheat Sheet - pdf

If you find this useful then post your feedback as comments and share it.

Happy to share and good luck for your exam.

Note: Since I love all those astro, codey etc characters that's why I have used those almost every pages.

Further Reading


Thursday, August 27, 2020

Tips for passing Salesforce certified JavaScript Developer I Certification

 Motivation behind this


Today (27th of August, 2020), I have successfully passed JavaScript Developer I Certification. I have been working on JavaScript from a long time along with Lightning Web Components and it has evolved a lot from last few years with ECMA script.

As Salesforce has come up with this exclusive certification with JavaScript language which drives me to learn and earn this which eventually will help me on LWC and other open source development.

This certification is on high demand now-a-days which motivates me to pass and share my tips.

I have given myself around 3 weeks of study time and happy to see me passed. By the way, this exam is tricky and actually challenges the depth of JavaScript knowledge.

Let's get started!



Exam Outline

This certification is comprised of two parts as below:


Multiple Choice Exam

  • Content: 60 multiple-choice/multiple-select questions and 5 non-scored questions 
  • Time allotted to complete the exam: 105 minutes
  • Passing score: 65% (approx 39 questions to be corrected)
  • Registration fee: 200 USD
  • Delivery options: Online proctored or onsite proctored delivery. 
  • Prerequisite: None

There were no questions from Lightning Web Components at MCQ.

Lightning Web Components Specialist Superbadge




Exclusive Trailmix and Trail:

Preparation


According to my personal choice, I have first targeted to pass MCQ exam and then worked on LWC superbadge.

I have attended Certification Preparation for Salesforce JavaScript Developer I (CRT-600) and finally gone through practice questions following explanations to solve those which immensely helped to pass this exam.


Topics to Consider for Exam


Most of the questions are lengthy code executions and output oriented. Here are following points to be consider along with the syllabus.

Variables, types and Collections
  • Different types of Primitive datatypes, Primitive Wrapper, Object variables
  • Truthy and falsey evaluations. For example 0, NaN, undefined are falsey
  • Difference between == and === operators
  • Scenarios of using var, let and const
  • Different ways of declaring objects
  • JSON transformations
  • Collections (Array, Map, Set) and their functions
  • String Functions
  • Different ways of creating arrays
  • Array methods, refer Array
Refer:  Grammar & Types

Objects, Functions and Classes
  • Function declarations, calling functions, handling recursions
  • Arrow functions
  • Create an instance of using Class, Function
  • Inheritance and use of super keyword
  • Use of Prototype,  Refer Object,Prototype
  • Use of this
  • Spread Syntax
  • High order functions like Sort, Map, Filter, Reduce
  •  
Refer: ObjectFunctions

Browser and Events
  • Accessing DOM elements
  • Use of getElementById, querySelector, querySelectorAll. Refer querySelector
  • Event propagation and effectively stopping that
  • Raising CustomEvent
Debugging and Error Handling
    Asynchronous Programming
    • Callback functions
    • Async functions with Promise 
    • Order of execution when Await with setTimeout, setInternal along with Promise methods and states are involved

     Server side JavaScript 
    • Importing (named, default) and using Node.js functions Refer Node.js API
    • Packaging files, checking dependencies, versioning (Major, Minor, Patch)
    Testing
    Hope it will help you to prepare and pass this exam.

    Further Reading


    Sunday, August 2, 2020

    Tips for passing Salesforce Marketing Cloud Email Specialist Certification

    Motivation behind this


    Yesterday (1st of August, 2020), I have successfully passed Marketing Cloud Email Specialist Certification. This is my debut exam on Marketing Cloud Space which I have started exploring lately. This certification is pre-requisite for other Marketing Cloud related certifications so tried to finish it.

    Salesforce is providing guidance on certification preparations through Partner Portal which helps me to prepare and pass this exam.

    Hope it might help others to get a quick guidance.

    Exam Outline


    • Prerequisite: None required; Email Essentials (EEB101) course attendance is highly recommended (Content Builder is covered in this course).
    • Exam Format: 60 multiple-choice/multiple-select questions
    • Time allotted to complete the exam: 90 minutes
    • Passing score: 65% (approx 39 questions to be corrected)
    • Registration fee: 200 USD
    • Delivery options: Online proctored or onsite proctored delivery. 
    • Results: Provided immediately after exam submission as on-screen text and by email.

    I have given myself 35 hours time-frame only for certification through the trailmix materials and sessions shared by Salesforce for partners and happy to see me passed.



    Preparation







    There are many questions are available on googling but Salesforce has changed those, so only on the knowledge on the subject will help to pass this exam.

    Topics to Consider for Exam



    • Email Marketing Best Practices
      • Powerful Email Strategies with personalization, optimizing for mobiles
      • CAN-SPAM requirements (2 questions), transnational vs commercial, unsubscribing from Master and Global list, include physical address
      • Different ways of unsubscribing, mechanisms for opt-out
      • Different ways for improving deliverabilities where purging old emails, authenticating emails etc.
      • Different ways of subscriber acquisitions like opt-in in-store, website signup, mobile opt-in etc
    • Email Message Design
      • Mobile-aware design
      • Responsive design
      • Showing images on mobile
      • Clear call-to-action
      • A/B testing (2 questions) scenario based
      • Content Detective for spam filtering
      • Validations for unsubscribing and physical mailing address
      • Dynamic Content (3-4 questions)
      • Send Preview and Test Preview
      • Approval processes
      • Read Email Design Toolkit  
      • Read Email Design Best Practices (2-3 questions)
    • Content Creation and Delivery
      • Content Builder and its usage in different scenarios
      • Asset sharing
      • Use of different types of content blocks
      • Individualize contents with AMPScripts, Dynamic Contents ; Personalized Strings 
      • User-initiated flow vs. A/B testing
      • Scenarios on send classification with Sender and Delivery profile
    • Subscriber and Data Management
      • Data Extension and List (3-4 questions), when to use what
      • Use of Subscriber key and Primary Key
      • Import Data with Import Wizard and Import Activity
      • Filters and Queries
      • Query Activity (3 questions)
    • Marketing Automation
      • Read Automation Studio Activities  (Data Extract, Filter Activity, SQL Query Activity etc.)
      • Triggered Email scenario
      • Automation File Drop scenario
      • File Transfer
      • Journey Builder scenario (with version, goal)
    • Tracking and Reporting
    Hope it will help you to prepare and pass this exam.

    Friday, July 24, 2020

    Consolidated list of Learning Programs to win Free or Discounted Salesforce Certification Vouchers

    Motivation behind this


    Many a times, I have received request from various Salesforce Trailblazers that if there are any certification programs are going on to avail discounted or free vouchers.

    There are many promotional campaigns and engagements are going on at Salesforce ecosystem where people can take full benefit of it.

    So, I have tried to prepare a consolidated list at the best of my knowledge and search. Hoping to see people get benefited where all the programs are free of cost.

    1) Journey to Salesforce Program (#Journey2Salesforce)


    This is a game changer for one's career who wants to transform them to Salesforce. See the features below:
    • Is Online and free
    • Facilitates employer connections
    • Has no deadlines
    • Offers mentorship from the Trailblazer community
    • Offers a chance to win certification vouchers and other goodies

    Referral Voucher Opportunity:

    Refer your friends to #Journey2Salesforce program and you could win a $400 certification voucher when they finish their program.

    How to refer:

    1. Invite your friends and family to register for the Journey2Salesforce Program in India.

    2. Referees must enter your email id when signing up, and complete the Journey2Salesforce Program during the Referral Program Period.

    3. Top 20 Referrers each month will win a $400 certification voucher.




    Note: This program is only for legal residents of India. Students with no work experience and professionals who are already working in the Salesforce ecosystem are also not eligible for the program.

    2) Trailhead Quests (#TrailheadQuest)


    This offers to learn new skills and win prizes.

    Link to register Trailhead Quests and check for the offers



    3) Level Up Challenge


    Join Level Up Challenge and get ready to earn your credential. Choose the Administrator or Developer career path, and Salesforce will support you with relevant learning through Trailhead Superbadge Super Sets (or super set)
    Super Sets are a collection of Superbadges, skill-based, domain-level credentials that prove your Salesforce expertise. While supplies last, eligible participants who complete a Super Set will earn a voucher to sit for a Salesforce certification exam ($200 value)*. 

    Link to register: Join Level Up Challenge


    Complete your superbadges to claim


    4) Salesforce Certification Days


    This is one of my favorite structure program and based on which many trailblazers have passed certifications.
    This is conducted by Salesforce with half-day webinar and currently it is offering $40 discounted voucher.

    Right now, it is conducting following certifications and also providing guided trailmixes.

    • Administrator
    • Advanced Administrator
    • Marketing Cloud Email Specialist
    • Platform App Builder
    • Platform Developer
    • Sales Cloud
    • Service Cloud
    Link to register: Upcoming Certification Days

    5) Partner Learning Camp


    This is expert training program for all the Salesforce partners.

    As per latest announcement, it is offering following Fast Path courses and $200 voucher discount on following certifications:

    • CPQ
    • Marketing Cloud Developer
    • Community Cloud
    • Service Cloud (coming soon)
    • Field Service (coming soon)

    Link to register: Partner Learning Camp




    And also join in this Marketing Cloud for Partners group to hear more announcement like below.

    Eligible participants who complete a Fast Path Course on the Partner Learning Camp eligible to receive a $200 USD certification voucher to take the certification exam that corresponds with the course completed. Offer only valid while supplies last and subject to chance. Limit one (1) voucher per person. Participants must register for and take their selected certification exam by or before January 31, 2021. Vouchers are non-transferable, not redeemable for cash, and eligible for use by recipient only. No refunds will be provided for exam fees paid prior to effective date, on exam fees paid when there was a redeemable voucher, or for unused vouchers. Additional restrictions may apply. 

    Refer: FastPathFAQ


    6) Participation at Trailblazer Community Hosted Programs


    There are exciting learning programs and events are hosted by Community Leaders, be part of this event and get a chance to win vouchers and goodies.

    Link to sign up: Trailblazer Community Groups

    At the end, we will learn and that's great takeaway from these programs.

    Happy Learning!