ExamGecko
Home Home / Salesforce / Certified B2B Commerce Administrator

Salesforce Certified B2B Commerce Administrator Practice Test - Questions Answers, Page 21

Question list
Search
Search

List of questions

Search

A developer needs to make a call to a long running web service which is critical to finalizing their checkout process. Which three items should the developer consider in their implementation?

A.
A new CORS entry may need to be created in Setup
A.
A new CORS entry may need to be created in Setup
Answers
B.
A new Named Credential may need to be created in Setup
B.
A new Named Credential may need to be created in Setup
Answers
C.
An Apex method returning a Continuation will need to be created
C.
An Apex method returning a Continuation will need to be created
Answers
D.
Requests to the service should be brokered to prevent limit exceptions
D.
Requests to the service should be brokered to prevent limit exceptions
Answers
E.
A new Remote Site may need to be created in Setup
E.
A new Remote Site may need to be created in Setup
Answers
Suggested answer: A, B, C

Explanation:

To make a call to a long running web service, a developer should consider the following items in their implementation:

A new CORS entry may need to be created in Setup.CORS stands for Cross-Origin Resource Sharing, and it is a mechanism that allows web browsers to make requests to servers on different origins1.A CORS entry defines a trusted origin for an external web service and allows the browser to access its resources2.If the web service is not on the same origin as the Salesforce org, a CORS entry is required to avoid cross-origin errors3.

A new Named Credential may need to be created in Setup.A Named Credential specifies the URL of an external web service and its authentication settings4.It can also store certificates or secrets for secure communication4.By using a Named Credential, a developer can simplify the callout code and avoid hardcoding sensitive information5.

An Apex method returning a Continuation will need to be created.A Continuation is a class in Apex that allows making long-running requests to external web services without blocking the user interface6.It works by sending the request asynchronously and returning a placeholder response that can be used to resume the processing later6.A Continuation can handle requests that take up to 120 seconds, which is longer than the normal limit of 10 seconds for synchronous callouts7.Reference:Cross-Origin Resource Sharing (CORS),Create a CORS Whitelist Entry,Make Long-Running Callouts with Continuations,Named Credentials,Apex Web Services and Callouts,Continuation Class,Apex Governor Limits

Which Lightning web component path allows a developer to view or edit a record while maintaining control over specifying its layout and set of fields?

A.
lightning-record-edit-form
A.
lightning-record-edit-form
Answers
B.
lightning-record-imperative
B.
lightning-record-imperative
Answers
C.
lightning-record-view-form
C.
lightning-record-view-form
Answers
D.
lightning-record-form
D.
lightning-record-form
Answers
Suggested answer: A

Explanation:

The lightning-record-edit-form component allows a developer to view or edit a record while maintaining control over specifying its layout and set of fields. It is a wrapper component that accepts a record ID and an object API name, and displays fields with their labels and current values. The developer can use lightning-input-field components inside the lightning-record-edit-form to create editable fields, and lightning-output-field components or other display components to show read-only information. The lightning-record-edit-form component also implements Lightning Data Service, which means it does not require additional Apex controllers to create or update records, and it handles field-level security and sharing automatically.

A developer has created a custom Lightning web component for the Cart page that needs to react to changes to cart items from the standard cart component.

How should the developer implement the custom component so changes to cart items and quantities are reflected?

A.
Subscribe to events on the lightning_commerce_cartChanged channel using the Lightning Message Service.
A.
Subscribe to events on the lightning_commerce_cartChanged channel using the Lightning Message Service.
Answers
B.
Add a listener for the cartltemUpdate Lightning event.
B.
Add a listener for the cartltemUpdate Lightning event.
Answers
C.
Listen for events on the lightning_commerce_cartChanged channel with the Lightning Event ''Listener component.
C.
Listen for events on the lightning_commerce_cartChanged channel with the Lightning Event ''Listener component.
Answers
D.
Add an event listener for the cartchanged DOM (Document Object Model) event.
D.
Add an event listener for the cartchanged DOM (Document Object Model) event.
Answers
Suggested answer: A

Explanation:

The Lightning Message Service (LMS) is a feature that allows communication across different UI technologies, such as Lightning Web Components, Aura Components, and Visualforce pages. LMS uses message channels to publish and subscribe to messages.A message channel is a custom metadata type that defines the shape and scope of the messages1.The lightning_commerce_cartChanged channel is a standard message channel that is used by the B2B Commerce Cloud platform to notify components of changes to the cart items and quantities2. A developer can use the LMS API to subscribe to events on this channel and update the custom component accordingly.The developer needs to import the lightning/messageService module and the lightning_commerce_cartChanged channel in the JavaScript file of the custom component, and then use the subscribe method to register a callback function that handles the message payload3. For example:

// cartCustomComponent.js import { LightningElement, wire } from 'lwc'; import { subscribe, MessageContext } from 'lightning/messageService'; import CART_CHANGED_CHANNEL from '@salesforce/messageChannel/lightning_commerce_cartChanged__c';

export default class CartCustomComponent extends LightningElement { // Declare a message context @wire(MessageContext) messageContext;

// Declare a subscription variable subscription = null;

// Subscribe to the message channel in the connected callback connectedCallback() { this.subscribeToMessageChannel(); }

// Subscribe to the message channel using the LMS API subscribeToMessageChannel() { if (!this.subscription) { this.subscription = subscribe( this.messageContext, CART_CHANGED_CHANNEL, (message) => this.handleCartChange(message) ); } }

// Handle the message payload and update the component logic handleCartChange(message) { // Do something with the message payload, such as: // - Display the cart items and quantities // - Calculate the cart total // - Apply discounts or taxes // - etc. } }

Which category can receive signaling from a Lightning Message Channel? 03m 42s

A.
only descendents (i.e. children)
A.
only descendents (i.e. children)
Answers
B.
page (anywhere on it)
B.
page (anywhere on it)
Answers
C.
only direct siblings
C.
only direct siblings
Answers
D.
only ancestors (i.e. parents)
D.
only ancestors (i.e. parents)
Answers
Suggested answer: B

Explanation:

The Lightning Message Service (LMS) allows communication across different UI technologies on a Lightning page, such as Lightning Web Components, Aura Components, and Visualforce pages. LMS uses message channels to publish and subscribe to messages.A message channel is a custom metadata type that defines the shape and scope of the messages1. The scope of a message channel determines which components can receive signaling from it.There are two possible scopes: application and component1.The application scope means that any component on the page can receive signaling from the message channel, regardless of its position in the DOM hierarchy1.The component scope means that only components that share a common ancestor can receive signaling from the message channel1. Therefore, the correct answer is B. page (anywhere on it), because it corresponds to the application scope of a message channel.Reference:Use Lightning Message Service

Which two methods should a developer implement in a Lightning web component to 03m 355

successfully handle the subscription lifecycle of a Message Channel?

A.
Subscribe()
A.
Subscribe()
Answers
B.
stopListener()
B.
stopListener()
Answers
C.
startListener()
C.
startListener()
Answers
D.
unsubscribe()
D.
unsubscribe()
Answers
Suggested answer: A, D

Explanation:

To handle the subscription lifecycle of a Message Channel, a developer should implement two methods in a Lightning web component: subscribe() and unsubscribe(). The subscribe() method is used to register a callback function that handles the messages published on the message channel. The unsubscribe() method is used to remove the subscription and stop receiving messages.Both methods are part of the Lightning Message Service API, which is imported from the lightning/messageService module1. For example:

// Import the Lightning Message Service API import { subscribe, unsubscribe, MessageContext } from 'lwc/messageService';

// Declare a message context @wire(MessageContext) messageContext;

// Declare a subscription variable subscription = null;

// Subscribe to the message channel in the connected callback connectedCallback() { this.subscribeToMessageChannel(); }

// Subscribe to the message channel using the LMS API subscribeToMessageChannel() { if (!this.subscription) { this.subscription = subscribe( this.messageContext, MESSAGE_CHANNEL, // The name of the message channel (message) => this.handleMessage(message) // The callback function ); } }

// Unsubscribe from the message channel in the disconnected callback disconnectedCallback() { this.unsubscribeFromMessageChannel(); }

// Unsubscribe from the message channel using the LMS API unsubscribeFromMessageChannel() { unsubscribe(this.subscription); this.subscription = null; }

Which practice is allowed when it comes to naming a Lightning web component's folder and associated files?

A.
Including whitespace
A.
Including whitespace
Answers
B.
Using a single underscore
B.
Using a single underscore
Answers
C.
Using consecutive underscores
C.
Using consecutive underscores
Answers
D.
Using a single hyphen (dash)
D.
Using a single hyphen (dash)
Answers
Suggested answer: B

Explanation:

Using a single underscore because this is allowed when it comes to naming a Lightning web component's folder and associated files.However, it is not recommended because it does not map to kebab case in markup, which is the convention for web components2. The other options are incorrect because they violate the naming rules for Lightning web components.The folder and its files must follow these naming rules3:

Must begin with a lowercase letter

Must contain only alphanumeric or underscore characters

Must be unique in the namespace

Can't include whitespace

Can't end with an underscore

Can't contain two consecutive underscores

Can't contain a hyphen (dash)

Which element can be used to pass HTML from a parent component to a child component?

A.
<html></htmi>
A.
<html></htmi>
Answers
B.
<template></template>
B.
<template></template>
Answers
C.
C.
Answers
D.
<slot></slot>
D.
<slot></slot>
Answers
Suggested answer: D

Explanation:

<target>lightningCommunity_Page</target> because this is the element that should be included in the component's configuration XML file to make the custom component available for the Product Detail page in the store.The target element specifies where the component can be used, and the lightningCommunity_Page value indicates that the component can be used on any Experience Builder page1. The other options are incorrect because they either use invalid or irrelevant elements or values.For example, the builder element is not a valid element for Lightning web components2, the RecordPage value is not a valid target for Lightning web components3, and the isAvailable and isExposed elements are not required for Lightning web components4.Reference:Target a Page Type,Component Configuration File,Target Config File,Expose a Component to Experience Builder

A developer has created a custom Lightning web component to display on the Product Detail 03m 10s page in the store. When the developer goes to add the component to the page in Experience Builder, it is missing from the list of custom components.

Which XML fragment should the developer include in the component's configuration XML file to ensure the custom component is available to add to the page?

A.
<builder>ExperienceCloud</builder> <target>RecordPage</target>
A.
<builder>ExperienceCloud</builder> <target>RecordPage</target>
Answers
B.
<isExposed target='ExperienceCloud'> | RecordPage i </isExposed>
B.
<isExposed target='ExperienceCloud'> | RecordPage i </isExposed>
Answers
C.
<isAvailable>true</isAvailable> <targets=lightningCommunity_RecordPage<targets> <isExposed>true</isExposedTrue> <targets>
C.
<isAvailable>true</isAvailable> <targets=lightningCommunity_RecordPage<targets> <isExposed>true</isExposedTrue> <targets>
Answers
D.
<target=lightningCommunity_Page</target> <targets>
D.
<target=lightningCommunity_Page</target> <targets>
Answers
Suggested answer: B

Explanation:

<slot></slot> because this is the element that can be used to pass HTML from a parent component to a child component.The slot element is a placeholder for content that is defined in the parent component and inserted into the child component5.It allows creating reusable components with dynamic content6. For example, suppose there is a parent component that defines some HTML content inside a child component:

<!-- parent.html --> <template> <c-child>

This is some HTML content passed from the parent to the child. </c-child> </template>

The child component can use the slot element to render the content from the parent:

<!-- child.html --> <template> <h1>This is the child component.</h1> <slot></slot> <!-- This will display the content from the parent --> </template>

The output will look like this:

This is the child component. This is some HTML content passed from the parent to the child.

A developer is building a custom component in Lightning web components (LWC) that has a grandchild component that needs to pass information to the grandparent component. Ex Ther m Ss

What is the correct way to demonstrate the passing of a message from the grandchild component to the grandparent component?

A)

B)

C)

D)

A.
Option A
A.
Option A
Answers
B.
Option B
B.
Option B
Answers
C.
Option C
C.
Option C
Answers
D.
Option D
D.
Option D
Answers
Suggested answer: A

Explanation:

The correct way to demonstrate the passing of a message from the grandchild component to the grandparent component is by using an attribute on the child component to pass the message. This can be done by using the @api decorator in the grandchild component and then handling the message in the grandparent component with the handlemessage method. For example:

<!-- grandchild.html --> <template> <lightning-button label=''Send Message'' onclick={handleClick}></lightning-button> </template>

// grandchild.js import { LightningElement, api } from 'lwc';

export default class Grandchild extends LightningElement { // Declare an attribute to pass the message @api message = 'Hello from grandchild';

// Handle the button click and fire an event handleClick() { // Create a custom event with the message as detail const event = new CustomEvent('message', { detail: this.message }); // Dispatch the event from this component this.dispatchEvent(event); } }

<!-- child.html --> <template> <c-grandchild onmessage={handleMessage}></c-grandchild> </template>

// child.js import { LightningElement } from 'lwc';

export default class Child extends LightningElement { // Handle the message event from the grandchild component handleMessage(event) { // Get the message from the event detail const message = event.detail; // Fire another event with the same message to pass it to the parent component this.dispatchEvent(new CustomEvent('message', { detail: message })); } }

<!-- parent.html --> <template> <c-child onmessage={handleMessage}></c-child> </template>

// parent.js import { LightningElement } from 'lwc';

export default class Parent extends LightningElement { // Declare a property to store the message message;

// Handle the message event from the child component handleMessage(event) { // Get the message from the event detail and assign it to the property this.message = event.detail; // Do something with the message, such as display it on the screen console.log(this.message); } }

What are two purposes of the Shadow DOM in a Lightning web component?

A.
It encapsulates the internal document object model (DOM) structure of a web component
A.
It encapsulates the internal document object model (DOM) structure of a web component
Answers
B.
It allow components to be shared while protecting them from being manipulated by arbitrary code
B.
It allow components to be shared while protecting them from being manipulated by arbitrary code
Answers
C.
It allows direct access to the document object model of the component
C.
It allows direct access to the document object model of the component
Answers
D.
It allows older JavaScript libraries to manipulate the tagging structure
D.
It allows older JavaScript libraries to manipulate the tagging structure
Answers
Suggested answer: A, B

Explanation:

The Shadow DOM is a standard that provides encapsulation for the internal document object model (DOM) structure of a web component. The DOM is the representation of the HTML elements and attributes of a web page in a tree-like structure. The Shadow DOM allows creating a separate DOM tree for each web component, which is hidden from the main DOM tree.This means that the markup, style, and behavior of the web component are isolated from the rest of the page1. The purposes of the Shadow DOM in a Lightning web component are:

It encapsulates the internal document object model (DOM) structure of a web component. This means that the web component has its own scope and namespace, and does not interfere with other elements on the page.For example, the web component can use its own CSS selectors and variables without affecting or being affected by the global CSS2.The web component can also use custom HTML tags without conflicting with existing or future HTML standards3.

It allows components to be shared while protecting them from being manipulated by arbitrary code. This means that the web component can be reused in different contexts and applications, without worrying about external code changing its functionality or appearance.For example, the web component can be embedded in another web page or application, and it will still work as intended, regardless of the surrounding code4.The web component can also prevent malicious code from accessing or modifying its internal state or data5.

Total 256 questions
Go to page: of 26