ExamGecko
Home Home / Salesforce / Certified B2B Commerce Developer

Salesforce Certified B2B Commerce Developer Practice Test - Questions Answers

Question list
Search
Search

A developer needs to create an event listener on a parent component programmaticallv. With the script below, what should replace the text <EVENT LISTENER UNE>?

A.
this.template.addEventListener(handleNotification);
A.
this.template.addEventListener(handleNotification);
Answers
B.
this.template.addEventListener(this.handleNotification);
B.
this.template.addEventListener(this.handleNotification);
Answers
C.
this.template.addEventListenerCnotification1, this.handleNotification);
C.
this.template.addEventListenerCnotification1, this.handleNotification);
Answers
D.
addEventListener('notifJcatiorV, this.handleNotification);
D.
addEventListener('notifJcatiorV, this.handleNotification);
Answers
Suggested answer: C

Explanation:

To create an event listener on a parent component programmatically, the developer should use the following line of code:

this.template.addEventListener('notification', this.handleNotification);

This line of code adds an event listener to the template element of the parent component, which is the root element that contains all the child elements. The event listener listens for an event named 'notification', which is a custom event that can be dispatched by any child component. The event listener invokes a method named handleNotification, which is an arrow function defined in the parent component class. The handleNotification method receives the event object as a parameter and can perform any logic based on the event data. The other lines of code are either incorrect or incomplete. Salesforce

Reference: Lightning Web Components Developer Guide: Communicate with Events, Lightning Web Components Developer Guide: Create and Dispatch Events

A developer has the task to create custom Lightning web components (LWCs). Which two steps must a developer take when creating custom LWCs?

A.
Create an Apex class.
A.
Create an Apex class.
Answers
B.
Authorize an org for an SFDX project.
B.
Authorize an org for an SFDX project.
Answers
C.
CloneaLWC.
C.
CloneaLWC.
Answers
D.
Deploy a custom component.
D.
Deploy a custom component.
Answers
Suggested answer: B, D

Explanation:

To create custom Lightning web components (LWCs), a developer must take two steps: authorize an org for an SFDX project and deploy a custom component. Authorizing an org for an SFDX project allows the developer to connect to a Salesforce org, such as a scratch org, a sandbox, or a production org, and use it as a development environment. Deploying a custom component allows the developer to push the LWC code from the local project to the org and make it available for use. Creating an Apex class is not a required step for creating custom LWCs, as not all LWCs need to use Apex. Cloning an LWC is not a required step either, as it is an optional way to create a new LWC based on an existing one. Salesforce

Reference:Lightning Web Components Developer Guide: Authorize an Org for Development,Lightning Web Components Developer Guide: Deploy Your Component

Which two event settings are required for a custom event called CustomEvent to fire from the Lightning web component and propagate up to the DOM?

A.
bubbles: true
A.
bubbles: true
Answers
B.
composed: true
B.
composed: true
Answers
C.
cancelable: true
C.
cancelable: true
Answers
D.
composed: false
D.
composed: false
Answers
Suggested answer: A, B

Explanation:

To fire a custom event called CustomEvent from the Lightning web component and propagate it up to the DOM, the developer must set two event settings: bubbles and composed. The bubbles setting determines whether the event bubbles up through the component's ancestors in the DOM tree. The composed setting determines whether the event crosses the shadow boundary and reaches the light DOM. Setting both bubbles and composed to true allows the event to be handled by any element in the DOM that listens for it. The cancelable setting is not required for firing or propagating the event, as it only determines whether the event can be canceled by calling preventDefault() on it. Setting composed to false would prevent the event from reaching the light DOM and limit its propagation to the shadow DOM. Salesforce

Reference:Lightning Web Components Developer Guide: Create and Dispatch Events,Lightning Web Components Developer Guide: Event Propagation

How can a developer establish communication between components that are not in the same DOM (Document Object Model) tree?

A.
Use publish-subscribe pattern.
A.
Use publish-subscribe pattern.
Answers
B.
Configure targets property.
B.
Configure targets property.
Answers
C.
Use dispatch events.
C.
Use dispatch events.
Answers
D.
Use @api decorators.
D.
Use @api decorators.
Answers
Suggested answer: A

Explanation:

To establish communication between components that are not in the same DOM (Document Object Model) tree, a developer can use the publish-subscribe pattern. The publish-subscribe pattern is a messaging pattern that allows components to communicate with each other without being directly connected or aware of each other. The components can publish events to a common channel and subscribe to events from that channel. The channel acts as a mediator that delivers the events to the subscribers. The developer can use a custom library or a Salesforce platform service, such as Lightning Message Service or Platform Events, to implement the publish-subscribe pattern. Configuring the targets property is not a way to communicate between components that are not in the same DOM tree, as it only defines where a component can be used in an app. Using dispatch events is not a way either, as it only works for components that are in the same DOM tree or have a parent-child relationship. Using @api decorators is not a way either, as it only exposes public properties or methods of a component to other components that use it. Salesforce

Reference:Lightning Web Components Developer Guide: Communicate Across Salesforce UI Technologies,Lightning Web Components Developer Guide: Communicate with Events, [Lightning Web Components Developer Guide: Communicate with Properties]

Which two guidelines should a developer consider when migrating aura components to LWC?

A.
Migrate one component and then determine whether additional effort would make sense
A.
Migrate one component and then determine whether additional effort would make sense
Answers
B.
Start with migrating trees of components (components within components)
B.
Start with migrating trees of components (components within components)
Answers
C.
Force all developers to write any new components using Lightning web components
C.
Force all developers to write any new components using Lightning web components
Answers
D.
Start with simple components that only render Ul
D.
Start with simple components that only render Ul
Answers
Suggested answer: A, D

Explanation:

When migrating aura components to LWC, a developer should consider two guidelines: migrate one component and then determine whether additional effort would make sense and start with simple components that only render UI. Migrating one component and then determining whether additional effort would make sense allows the developer to evaluate the benefits and costs of migration and decide whether to continue or stop. Migrating simple components that only render UI allows the developer to leverage the performance and modern features of LWC without much complexity or dependency on other components or services. Starting with migrating trees of components (components within components) is not a good guideline, as it can introduce more challenges and dependencies that can complicate the migration process. Forcing all developers to write any new components using Lightning web components is not a good guideline either, as it can create inconsistency and confusion among developers and users. Salesforce

Reference: [Lightning Web Components Developer Guide: Migrate Aura Components to Lightning Web Components], [Lightning Web Components Developer Guide: Migration Considerations]

What are two considerations to keep in mind when including additional JavaScript files in a Lightning web component?

A.
Each additional file needs a corresponding .js-meta.xml file.
A.
Each additional file needs a corresponding .js-meta.xml file.
Answers
B.
The files must be ES6 modules and must have names that are unique within the component's folder.
B.
The files must be ES6 modules and must have names that are unique within the component's folder.
Answers
C.
A module can export named functions or variables
C.
A module can export named functions or variables
Answers
D.
Additional JavaScript files should be minified before deployment
D.
Additional JavaScript files should be minified before deployment
Answers
Suggested answer: B, C

Explanation:

When including additional JavaScript files in a Lightning web component, a developer should keep in mind two considerations: the files must be ES6 modules and must have names that are unique within the component's folder and a module can export named functions or variables. The files must be ES6 modules because LWC uses ES6 modules as the standard for modular JavaScript code. The files must have names that are unique within the component's folder because LWC uses the file name as the module identifier and does not allow duplicate identifiers. A module can export named functions or variables because LWC supports named exports, which allow a module to export multiple values with different names. Each additional file does not need a corresponding .js-meta.xml file, as this is only required for the main JavaScript file of the component. Additional JavaScript files should not be minified before deployment, as this is not necessary or recommended for LWC. Salesforce

Reference: [Lightning Web Components Developer Guide: Include JavaScript Files], [Lightning Web Components Developer Guide: ES6 Modules]

Which wire adapter should a developer use to retrieve metadata about a specific object?

A.
getObjectMetadata
A.
getObjectMetadata
Answers
B.
getObjectlnfo
B.
getObjectlnfo
Answers
C.
getObject
C.
getObject
Answers
D.
getObjectDescribe
D.
getObjectDescribe
Answers
Suggested answer: B

Explanation:

To retrieve metadata about a specific object, a developer should use the getObjectInfo wire adapter. The getObjectInfo wire adapter imports data from the @salesforce/schema module and returns an object that contains information such as the object's label, key prefix, fields, child relationships, record type infos, and theme. The getObjectMetadata wire adapter does not exist. The getObject wire adapter does not retrieve metadata, but rather returns a record object based on the record ID. The getObjectDescribe wire adapter does not exist either. Salesforce

Reference: [Lightning Web Components Developer Guide: getObjectInfo], [Lightning Web Components Developer Guide: Import Salesforce Schema]

Which code statement should a developer use to import the ID of the current Lightning Experience

A.
import id from '@salesforce/network/ld'
A.
import id from '@salesforce/network/ld'
Answers
B.
import id from '@salesforce/experience/ld'
B.
import id from '@salesforce/experience/ld'
Answers
C.
import id from '@salesforce/site/ld'
C.
import id from '@salesforce/site/ld'
Answers
D.
import id from '@salesforce/community/ld'
D.
import id from '@salesforce/community/ld'
Answers
Suggested answer: D

Explanation:

To import the ID of the current Lightning Experience community, a developer should use the following code statement:

import id from '@salesforce/community/Id';

The @salesforce/community module allows the developer to access information about the current community, such as its ID, name, URL, and base path. The other modules do not exist or are not related to the community ID. The @salesforce/network module is used to access information about the current network, such as its ID and name. The @salesforce/experience module is used to access information about the current user experience, such as whether it is standard or custom. The @salesforce/site module is used to access information about the current site, such as its name and prefix. Salesforce

Reference: [Lightning Web Components Developer Guide: Import Community Information], [Lightning Web Components Developer Guide: Import Salesforce Modules]

Which wire adapter should a developer use to retrieve metadata about a specific picklist?

A.
getPicklistMetadataValues
A.
getPicklistMetadataValues
Answers
B.
getPicklistMetadata
B.
getPicklistMetadata
Answers
C.
getPicklistValues
C.
getPicklistValues
Answers
D.
getPicklist
D.
getPicklist
Answers
Suggested answer: C

Explanation:

To retrieve metadata about a specific picklist, a developer should use the getPicklistValues wire adapter. The getPicklistValues wire adapter imports data from the @salesforce/ui-api module and returns an object that contains information such as the picklist's label, value, default value, validity, and controlling field values. The getPicklistMetadataValues wire adapter does not exist. The getPicklistMetadata wire adapter does not exist either. The getPicklist wire adapter does not exist either. Salesforce

Reference: [Lightning Web Components Developer Guide: getPicklistValues], [Lightning Web Components Developer Guide: Import User Interface API]

Which category can receive signaling from a Lightning Message Channel?

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

Explanation:

A Lightning Message Channel can receive signaling from any component on a page (anywhere on it). A Lightning Message Channel is a service that allows components to communicate with each other across different Salesforce UI technologies, such as Aura, LWC, Visualforce, and Lightning web apps. A component can subscribe to a message channel and receive events that are published by another component on the same or different page. The message channel acts as a mediator that delivers the events to the subscribers. A Lightning Message Channel does not receive signaling only from descendants (i.e., children), only from direct siblings, or only from ancestors (i.e., parents), as these are limitations of event-based communication. Salesforce

Reference: [Lightning Web Components Developer Guide: Communicate Across Salesforce UI Technologies], [Lightning Web Components Developer Guide: Communicate with Events]

Total 221 questions
Go to page: of 23