Friday, February 4, 2022

Display data from CMS using Lightning Web Component

 

Motivation behind this


We know that from B2B Commerce Lightning we can use readymade Lightning Web Components available through B2B Lex and use it for many purposes like Product Detail Card, Product Detail List, Cart Component, Order Summary etc. at Experience Cloud.
Refer B2B Commerce on Lightning Experience Components and it also fetches data from CMS.

What if I have to build similar LWC component which can be placed in Lightning RecordDetail page for internal users and data to be retrieved from CMS. This drives me to do a proof-of-concept and sharing you the steps to develop.





Use Case


Business wants to see the list of featured products for internal users and those product images are placed at CMS.

Developer wants to build LWC component to fetch records from CMS.

For sake of simplicity, those images will be displayed using lightning-carousel component.

Solution Approach


To start with, lets configure CMS and store images on CMS side.

Create CMS Workspace

From CMS Home Tab, Create CMS Workspace. Here given a name as Capricorn Store. Screen as follows:


Create a Channel

From Capricorn Store workspace, create a channel naming Capricorn Channel.




Add Content

Add 3 product related pictures as follows. For demo purpose I have used Coffee Machines pictures.


Sample product image and details will look like this:


Now let's create LWC component.

displayMediaFilesFromCMS.html

HTML will like below here lightning-carousel has been used.

<template>
    <lightning-card  title="Featured Products">
<div class="slds-medium-size_1-of-4 slds-align_absolute-center"> <lightning-carousel>
<template for:each={results} for:item="item"> <lightning-carousel-image key={item.title} src= {item.url} header= {item.title} href= {item.url}> </lightning-carousel-image>
</template> </lightning-carousel>
</div> </lightning-card>
</template>

displayMediaFilesFromCMS.js

Few notable things as follows:
  • Channel Name to be passed to Apex class's  retrieveMediaFromCMS() method using wire. For sake of simplicity channel name is hardcoded, it can be captured from design attributes too and using @api variable.
  • Loop through the array returned from Apex method and create new array with title and url as elements which will be used by carousel.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
import { LightningElement, track, wire } from 'lwc';
import retrieveMediaFromCMS from '@salesforce/apex/CMSConnectHelper.retrieveMediaFromCMS';

export default class DisplayMediaFilesFromCMS extends LightningElement {
    channelName = 'Capricorn Channel';
    @track results=[];
    @wire(retrieveMediaFromCMS,{channelName: '$channelName'})
    wiredData({ error, data }) {
        if (data) {
            let objStr = JSON.parse(data);
            objStr.map(element=>{
                this.results = [...this.results,{title:element.title,
                                                url:element.url}]
            });  
            this.error = undefined;            
        } else if (error) {
            this.error = error;
            this.results = undefined;
        }
    }
}


CMSConnectHelper.cls


Salesforce provides ConnectApi.ManagedContent class and its method to retrieve data from CMS. No need to fetch data using REST APIs. Refer documentation

 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
/**
 * @description       : This class is used to retrieve data from CMS
 * @author            : Santanu Boral
 * 
**/
public with sharing class CMSConnectHelper {
    
    @AuraEnabled (cacheable=true)
    public static String retrieveMediaFromCMS(String channelName){
        String channelId = getChannelId(channelName);

        //get the image content
        ConnectApi.ManagedContentVersionCollection obj = 
            ConnectApi.ManagedContent.getAllContent(channelId, 0, 5, 'en_US', 
                                                    'cms_image',false,
                                                    '2011-02-25T18:24:31.000Z','2021-09-25T18:24:31.000Z',true);
        
        List<ReturnWrapper> wrapperList = new List<ReturnWrapper>();
        System.debug('json value=' + JSON.serialize(obj));

        //loop through each item and prepare a wrapper list
        for(ConnectApi.ManagedContentVersion versionObj: obj.items){
            ReturnWrapper wrapper = new ReturnWrapper();
            wrapper.title = versionObj.title;
            
            //get the url
            Map<String,ConnectApi.ManagedContentNodeValue> contentNodesMap = versionObj.contentNodes;
            for(String str:contentNodesMap.keySet()){                
                if(str=='source'){
                    wrapper.url= ((ConnectApi.ManagedContentMediaSourceNodeValue)contentNodesMap.get(str)).url;
                }		
            }
            wrapperList.add(wrapper);	
        }
        return JSON.serialize(wrapperList);
    }

    @AuraEnabled (cacheable=true)
    public static String getChannelId(String channelName){
        ConnectApi.ManagedContentChannelCollection channelRepObj = 
                ConnectApi.ManagedContent.getAllDeliveryChannels(0,2);        

        //loop through the channels and return the channel Id
        for(ConnectApi.ManagedContentChannel channelObj: channelRepObj.channels){
            if(channelObj.channelName == channelName){
                return channelObj.channelId;
            }
        }
        return null;
    }

    public class ReturnWrapper{
        String title {get;set;}
        String url {get;set;}
    }
}

getAllContent() returns a JSON as follows which needs to be parsed to form title and url combination for each item elements.

 
  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
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
{
  "currentPageUrl": "/services/data/v51.0/connect/cms/delivery/channels/0ap2v000000Pu1w/contents/query?endDate=2021-09-25T18%3A24%3A31.000Z&language=en_US&managedContentType=cms_image&page=0&pageSize=5&startDate=2011-02-25T18%3A24%3A31.000Z",
  "items": [
    {
      "contentKey": "MCR6FJVMX4BRHSVJD4LPWUPPN3OI",
      "contentNodes": {
        "thumbUrl": {
          "nodeType": "Url",
          "value": "https://live.staticflickr.com/65535/49815666003_4973d84842.jpg"
        },
        "title": {
          "nodeType": "NameField",
          "value": "TR-COFMAC-001"
        },
        "source": {
          "fileName": null,
          "isExternal": true,
          "mediaType": "Image",
          "mimeType": null,
          "nodeType": "MediaSource",
          "referenceId": null,
          "resourceUrl": null,
          "unauthenticatedUrl": null,
          "url": "https://live.staticflickr.com/65535/49815666003_4973d84842.jpg"
        }
      },
      "contentUrlName": "tr-cofmac-001",
      "language": "en_US",
      "managedContentId": "20Y2v000000HbISEA0",
      "publishedDate": "2021-05-09T16:32:44.000Z",
      "title": "TR-COFMAC-001",
      "type": "cms_image",
      "typeLabel": "Image",
      "unauthenticatedUrl": "https://myinstance.my.salesforce.com/cms/delivery/v51.0/0ap2v000000Pu1wAAC/contents/20Y2v000000HbISEA0?oid=00D2v000002A3VoEAK"
    },
    {
      "contentKey": "MCSC6EEJVMZZB5HDHRKMTEQH6TIQ",
      "contentNodes": {
        "thumbUrl": {
          "nodeType": "Url",
          "value": "https://live.staticflickr.com/65535/49815637818_d892f8127d.jpg"
        },
        "title": {
          "nodeType": "NameField",
          "value": "E-ESP-001-1"
        },
        "source": {
          "fileName": null,
          "isExternal": true,
          "mediaType": "Image",
          "mimeType": null,
          "nodeType": "MediaSource",
          "referenceId": null,
          "resourceUrl": null,
          "unauthenticatedUrl": null,
          "url": "https://live.staticflickr.com/65535/49815637818_d892f8127d.jpg"
        }
      },
      "contentUrlName": "e-esp-001-1",
      "language": "en_US",
      "managedContentId": "20Y2v000000HbIIEA0",
      "publishedDate": "2021-05-09T16:32:06.000Z",
      "title": "E-ESP-001-1",
      "type": "cms_image",
      "typeLabel": "Image",
      "unauthenticatedUrl": "https://myinstance.my.salesforce.com/cms/delivery/v51.0/0ap2v000000Pu1wAAC/contents/20Y2v000000HbIIEA0?oid=00D2v000002A3VoEAK"
    },
    {
      "contentKey": "MCKPXLBGW36RDYXN75NDWFVTB5FA",
      "contentNodes": {
        "thumbUrl": {
          "nodeType": "Url",
          "value": "https://live.staticflickr.com/65535/49816090811_622af115a8.jpg"
        },
        "title": {
          "nodeType": "NameField",
          "value": "B-C-COFMAC-001"
        },
        "source": {
          "fileName": null,
          "isExternal": true,
          "mediaType": "Image",
          "mimeType": null,
          "nodeType": "MediaSource",
          "referenceId": null,
          "resourceUrl": null,
          "unauthenticatedUrl": null,
          "url": "https://live.staticflickr.com/65535/49816090811_622af115a8.jpg"
        }
      },
      "contentUrlName": "b-c-cofmac-001",
      "language": "en_US",
      "managedContentId": "20Y2v000000HbIDEA0",
      "publishedDate": "2021-05-09T16:28:55.000Z",
      "title": "B-C-COFMAC-001",
      "type": "cms_image",
      "typeLabel": "Image",
      "unauthenticatedUrl": "https://myinstance.my.salesforce.com/cms/delivery/v51.0/0ap2v000000Pu1wAAC/contents/20Y2v000000HbIDEA0?oid=00D2v000002A3VoEAK"
    }
  ],
  "total": 3
}

Finally, Create a Lightning App Builder page and place the component, it will look like this:


We are done and thanks for reading.

You can also extend this code to expose this component to Experience Cloud with some minor changes.


Further Reading


Saturday, January 22, 2022

Tips for passing Salesforce User Experience Designer Certification

 

Motivation behind this


Today 22nd January 2022, I have passed Salesforce User Experience Designer Certification and fortunately reached 30x certified. I have been trying this certification from quite a long time which gives a different dimensions of learning and exploring design options in human centric ways. This concepts behind this exam is thoughtful and definitely helps to execute project discovery, design, UI development and usability testing in proper ways.

Sharing my tips to prepare and pass this certification for trailblazers.





Exam Outline



Content: 60 multiple-choice / multiple-select questions
Time allotted to complete the exam: 105 minutes
Passing score: 65%
Registration fee: USD 200 plus applicable taxes as required per local law
Delivery options: Proctored exam delivered in an online proctored environment
References: No hard-copy or online materials may be referenced during the exam

Topics


Topics

Weighting

Discovery

13%

User Experience (UX) fundamentals

16%

Human-centered Design

12%

Declarative Design

27%

Testing

11%

Salesforce Lightning Design System (SLDS)

21%                

Preparation



Very nicely written blogs to refer:
Be sure to practice all the questions and flashcards from the preparation trailmix.

Few Important points to cover for exam


Discovery
  • UX Research Basics and Good Research Method (Behavioral, Attitudinal, Qualitative and Quantitative)
  • Common methods like: Surveys, Card Sorting activities (grouping things into categories), Contextual inquiry, Usability Testing)
  • Aim and Scope of study and how to formulate questions
  • Gathering data in Qualitative and Quantitative ways
  • Importance of Open ended questions
  • Tips on conducting research
  • Storytelling
  • User personas and their activities 
    • Sales Cloud Personas like Sales Leader, Deal Closer. Pipeline Builder
    • Service Cloud Personas like Case Solver, Expert Agent, Service Admin
    • Marketing Cloud Personas like Marketing Manager, Strategic Leader
    • Community Cloud Personas like Community End User, Community Manager, Community Admin
  • Process Mapping like Capability Model, Detailed Process Map, Value Stream Map and best practices 

UX Fundamentals
  • App Designing and Prototyping - creating low-fidelity prototypes, wireframing (scenarios given when to use what), interactive mockups for high fidelity
  • Whiteboarding and build your story, mocking up with Journey Builder and Experience Cloud
  • Mobile App Branding - creating branded App and what we can change like:
    • App Icon, App Name, Launch Screen, Color Scheme, Application Store, Authentication URL and Help URL
    • Distribute App via Apple App Store and Google Playstore
  • Lightning Experience for Salesforce Mobile App - App Launcher, Navigation Bar, Personalization of Navigation
  • What are ways we can customize that can be reflected on the mobile app.

Human-centered Design

  • Ways of Relationship Design - 
    • Difference and usefulness of User Experience Design and Service Design
    • Goals: Engagement, Connection, Social Values
    • How to strengthen employee relationships, community relationship
    • Mindsets of Relationship design - Compassion, Courage, Intention, Reciprocity
  • Web accessibility - 
    • Decorative vs. Informational
    • Importance of color, contrast requirement (4.5:1)
    • Animations and when to pause
    • Given a use case identify component states of a button 
  • Agile Basics - given a use case of estimation on user stories
  • Ethics by design - Equality and Inclusion in Salesforce Products
    • Transparency and accountability
    • Running Consequence scanning workshop

Declarative Design

  • Optimizing Sales Process through Path and what are the things can be included like (key fields, best practices, policy reminders, links to chatter posts)
  • Salesforce Adoption Strategies - given a scenario on sandbox to be identified for testing
  • User Engagement - 
    • Onboading, Feature discovery & adoption, Troubleshooting help and Deeper Learning. 
    • Components which are used and how (declarative way) for Welcome Mat, Prompts, Field-Level Help, Setup Assistant
    • Push vs Pull method
    • In-App guidance and choosing right type of prompt, M.A.P. (Message, Audience, Purpose)
  • Lightning Experience Features - 
    • Setting up navigations
    • Use of Help menu
    • Service setup flows
    • Account, Opportunity, Lead, Kanban view, path
    • Creating object relationship (Lookup, Master-Detail)
    • Service Console and Sales Console advantages over standard one
    • Knowledge publishing for different sets of users
    • Einstein chat bot and given a use case of post implementations and training requirement
    • Custom Themes and Branding specially for Experience Cloud
    • Dynamic Forms, Screen Flows, Lightning App Builder
  • Lightning Experience Customizations - 
    • Use of Compact Layout, Highlights Panel, List View with Filtering, Record visibility with field level security
    • Global Action, Object specific actions
Testing

Salesforce Lightning Design System (SLDS)
That's all I can remember and thanks for reading!

Further Reading for other certifications


Sunday, January 9, 2022

Tips for passing Salesforce Marketing Cloud Developer Certification

 

Motivation behind this


Today 9th January 2022, I have passed Salesforce Marketing Cloud Developer certification. Recently I have cleared Marketing Cloud Admin as well. As there are few concepts are common both for Developer and Admin which helps to expedite the preparation. Sharing my tips to prepare and pass this certification.


Exam Outline



Content: 60 multiple-choice / multiple-select questions (plus 5 unscored questions)
Time allotted to complete the exam: 105 minutes
Passing score: 63%
Registration fee: USD 200 plus applicable taxes as required per local law
Delivery options: Proctored exam delivered in an online proctored environment
References: No hard-copy or online materials may be referenced during the exam

Topics


Topics

Weighting

Data Modeling

14%

Programmatic Languages

35%

API

22%

Data Management

22%

Security

7%


Preparation


Dedicated 3 weeks focus study from Partner Learning Camp is good for preparation.


Also, blog written by Zuzzana Jarczynska has good collection Preparing for the Salesforce Marketing Cloud Developer certification

Few Important points to cover for exam


Data Modeling
  • Types of Data Extensions - Standard, Filtered, Custom
  • Non-sendable vs Sendable Data Extension and how records are added to Sendable DE
  • Contact Builder Features, use of Attribute Groups
  • From Contact Model - difference and usefulness of Contact Id, Contact Key and Subscriber Key
  • Data Retention Policies
  • Best practices of deleting 2 Million Contact Data
  • Steps of Deletion - Deletion process initiated, followed by Suppression Period, Final Deletion
  • Deletion using REST APIs using Contact ID, Contact Key or List
Programmatic Languages
  • AMPScript
    • Given a snippet of code to display the outcome
    • AMPScript Processing in this order: HTML Body -> Text Body  -> Subject Line
    • How to use a variable and attributes
    • Lookup. LookupRows functions
    • CONVERT and CASE
    • Math function specially DateAdd, DateDiff, Divide, Mod, Now(), RedirectTo, RaiseError, BeginImpressionRegion, EndImpressionRegion
  • SSJS
    • We can use Arrays and advanced error handling through SSJS over AMPScript
    • How to use AMPScript and SSJS together: Variable.GetValue("@myAmpVariable")
    • Platform Object support, along with Core and when to use what
    •  Error Handling with try-catch block
  • GTL
    • When to use it and advantages over SSJS
  • Exclusion Scripts
    • ROWCOUNT(LOOKUPROWS("Suppression", "Email Address",emailaddr))> 0;
    • Domain(emailaddr) != "mycompany.com"
API
  • Scenarios of using SOAP and REST API, their capabilities, limitations and when to use what
  • Use of Client Id, Client Secret and Authorization information as Header
  • GET and POST syntax for REST APIs
  • Transactional Messaging
  • Few important methods of SOAP: Configure, Execute, Extract, Create, Update, Delete
  • Few objects of SOAP: AccountUser, DataExtension, DataExtensionObject, Subscriber
  • When to process synchronously and asynchronously like TriggeredSends, queued calls
  • REST timeouts
  • Error Handling and how to solve errors.
  • Accessing Journey Builder, Content Builder, Event Notification Service from REST
  • Marketing Cloud SDK and where to find help
Data Management
  • File Import Considerations
    • FTP & File Drop Automation File Naming Pattern: %%BASEFILENAME_FROM_TRIGGER%%
    • Processing of encrypted files
  • Send Log and Data Retention Policies, less than 10 custom fields considerations, Contact Delete implications
  • SQL
    • Syntax of SELECT queries with different types of JOIN
    • Selecting All fields
    • Comparing with WHERE clause in performance optimized way
    • Data Views: Bounce, Open, Click
    • SQL Best practices: Staging the data, Consider when data is > 1M
Security
  • Encryption Methods: Asymmetric, Symmetric, Salt, Initiation Vector
  • Transparent Data Encryption
  • Tokenized Sending
  • Using SSL Certificate
There are around 20 sample questions can be found from fast path course at PartnerLearningCamp which are very effective.

Happy Learning!

Further Reading for other certifications




Wednesday, December 22, 2021

Tips for passing Salesforce OmniStudio Consultant Certification

 

Motivation behind this


Yesterday 21st December, 2021 I have passed Salesforce OmniStudio Consultant certification. Recently I have cleared OmniStudio Developer certification and since the certification content is based on those fundamentals which drives me to go for it.

Sharing my preparation and study tips for trailblazers to prepare and pass the exam.


Exam Outline



Content: 60 multiple-choice / multiple-select questions (plus 5 unscored questions)
Time allotted to complete the exam: 105 minutes
Passing score: 63%
Registration fee: USD 200 plus applicable taxes as required per local law
Delivery options: Proctored exam delivered in an online proctored environment
References: No hard-copy or online materials may be referenced during the exam

Topics


Topics

Weighting

FlexCards

23%

OmniScripts

27%

Data Tools

23%

Best Fit Solutioning

27%


Preparation



There are following blogs and resources to follow:
All hands on exercises from Trailheads
As this exam content is similar to OmniStudio Developer so except lower level coding part, main concepts will really help to pass this exam. and it has no pre-requisites, so it can also be taken up first.

Few Important points to cover for exam


There are following slides from Salesforce document

  • OmniStudio Architecture (at a glance)
    • Digital Experience - FlexCards, OmniScripts
    • Service Management - Integration Procedures, DataRaptors
    • Developer Experience - IDX Build Tool, IDX Workbench

  • OmniStudio FlexCards
    • Displaying data from multiple data sources
    • Dynamic Actions - Launch Pages, Services and more with Dynamic URLs
    • Display more information on demand with Flyouts
    • Multiple states, that display based on conditions
    • Use of Menu Item, Select, Radio, Datatable
    • Embedding FlexCards inside other FlexCards when exposing to the community
    • Purpose of Block elements, Text and field elements
    • Navigate action to a target URL
    • Firing PubSub events and Custom events and related DataRaptor actions
    • OmniStudio Action
    • Best practices on versioning and cloning a FlexCard

  • OmniScripts
    • Steps to display data from multiple data sources
    • Managing Signed documents
    • Document to download.
    • Performing validations when completing a form and Save for later.
    • OmniScripts elements like Actions, Groups, Inputs, Functions etc.

  • OmniStudio Integration Procedures
    • Handing multiple data sources
    • Integration Procedure Actions like Batch Action, different DataRaptor Actions, Response Action etc
    • Data Input - DataRaptor Extract Action or DataRaptor Turbo Action, HTTP and Remote Action
    • Data Output - Response Action, Email Action, DocuSign Envelop Action


  • OmniStudio DataRaptor
    • Use cases on each one of these DataRaptor Turbo Extract, Load, Extract and Transform.
    • DataRaptor Functions like Aggregate, DateTime
    • Creating pre-filled PDF documents through DataRaptor Transform
    • Turbo extract vs. Extract for optimization purpose

  • OmniStudio Calculation Procedures
    • Calculation Matrixes - Standard, Group and Row-versioned, when to use and what
    • Calculation Procedures - Use case for displaying summation
    • What are the use cases it supports
  • Read all the best practices
    • Use cases on using Integration Procedure over DataRaptor
    • Group multiple steps into single steps
    • Use of Flyouts when multiple elements clutter the screen
    • Use case of 360 view of Customer
    • Combining actions through Integration Procedures

Hope it helps to prepare and pass this exam.

Further Reading for other certifications



Sunday, December 19, 2021

Trailblazer Community Event: Journey2Salesforce - Inspiring Success Stories

 

Motivation behind this


We have successfully organized exciting session on Journey2Salesforce program and sharing the success stories of trailblazers. 

Name: Journey2Salesforce - Inspiring Success Stories

On: Sunday, December 19, 2021

Attendees: 66

Check ins: 32



Agenda


Following topics we have covered:

  • Introducing Salesforce through Journey2Salesforce Program
  • How does it help aspirants at their career and achieving prospecting jobs 
  • Motivate yourself hearing success stories
  • Forum for Q & A on Salesforce career guidance

By the end of this session, aspirants will get a guidance on Salesforce career path.

Journey Path







Discussion Points


We started on sharing the all information about Journey2Salesforce program. Aspirants can register here

These are the questions rather experience we shared during our session.

  1. Journey Path and details for each trailmixes
  2. Importance of Local Hub
  3. Sharing experiences on Employer Connect
  4. How did you come to know about Salesforce?
  5. Why Salesforce? 
  6. How did you come to know about Journey2Salesforce program? 
  7. How did this program motivate you to fulfill your journey?
  8. What motivates you to learn more on Salesforce?
  9. Did you ever attend any Trailblazer Community events or meet-ups?
  10. What's your plan for certifications in the coming months?
  11. What are the challenges you have undergone during this journey?
  12. Did you ever find a mentor to guide during this journey?
  13. How is your experience on job searching?
  14. How is your interview experience?
  15. Who has got offer this year 2021 and how’s your experience?
  16. What's the advice you will give for future aspirants?

Glimpse




Thank you for joining with us!