AP-202 Sample Questions & Answers
Weighted toward building new Lightning Web Components from scratch, the single biggest weight, plus basic LWC storefront tweaks, checkout and payment interfaces, customizing checkout flows, managing B2B Commerce data, and diagnosing errors.
Launch the full AP-202 simulator →Free AP-202 Sample Questions with Answers
Real questions from the B2B Commerce for Developers Accredited Professional practice test — answers and explanations included. Showing 10 of 20 free samples.
- Question 1Intermediate
Error Handling and Diagnostics · Guest User Security
A developer has modified an existing LWC on the cart page to display custom promotional messages. After deploying the changes, the component works correctly for authenticated users but fails to load for guest users, causing the entire cart page to show an error. The browser console shows a '403 Forbidden' error when the component's Apex controller is called. What is the most likely cause of this issue?
Show answer & explanation
Correct answer: B
For a guest user to be able to invoke an
@AuraEnabledmethod, the Guest User Profile for that specific Experience Cloud site must be granted explicit access to the Apex class. A '403 Forbidden' error is a classic symptom of this missing permission.with sharingcontrols record visibility, not class access. The@AuraEnabledannotation being missing would result in a different error, likely a 'method not found' on the client side. The store being inactive would prevent the entire page from loading. - Question 2Beginner
Data Management · Product Data Configuration
True or False: When creating a new custom field on the
Product2object to store technical specifications, this field will automatically be available to be displayed on the Product Detail Page through standard components without any further configuration.Show answer & explanation
Correct answer: B
False. After creating a custom field on an object like
Product2, a developer or administrator must take additional steps to make it visible on the storefront. This typically involves updating the component's properties in Experience Builder to include the new field or, for more complex components, modifying the component's underlying code to query and display the new field's data. Field-level security for the guest or buyer user profile must also be checked. - Question 3Advanced
Data Management · Custom Product Bundling Solution
Case Study: 'Helios Energy Solutions' Storefront Optimization
Company Background: Helios Energy Solutions provides advanced solar panel components to a network of certified installers. Their B2B Commerce storefront is built on the Aura template and has been live for two years. They manage a complex catalog of over 5,000 products with tiered pricing and availability rules based on installer certification levels (Bronze, Silver, Gold).
Current Situation: The marketing team wants to launch a new feature: 'Project Kits'. A Project Kit is not a standard product but a collection of products (e.g., 10 panels, 1 inverter, 1 mounting kit) that can be added to the cart with a single click. The components of a kit should be priced individually based on the installer's tier, but a 5% discount should be applied to each item if purchased as part of the kit. The contents of a kit are defined by the marketing team and change frequently.
Technical Requirements:
- The 'Project Kits' must be displayed on a new, dedicated page in the storefront.
- When a kit is added to the cart, all individual component products must be added as separate cart line items.
- A 5% adjustment must be applied to the price of each component line item originating from a kit.
- The solution must be manageable by a non-technical marketing user for creating and updating kits.
- The solution must scale and not negatively impact the performance of the cart and checkout process.
Problem: The development team is debating the best architectural approach to meet these requirements. Which of the following proposals represents the most scalable and maintainable solution using B2B Commerce best practices?
Show answer & explanation
Correct answer: C
This solution is the most robust and aligns with B2B Commerce extension patterns. 1) Using custom objects for kits allows marketing to manage them easily via standard Salesforce UI. 2) The custom LWC correctly encapsulates the 'add to cart' logic, using the standard Cart API to ensure compatibility. 3) Extending the pricing service (
ccrz.cc_hk_Pricing) is the correct, prescribed method for implementing custom pricing logic, such as a conditional discount, without modifying core code. This approach is scalable, maintainable, and separates data management from business logic correctly. - Question 4Intermediate
Basic Lightning Web Component Development · Data Display and Formatting
A developer needs to modify the display of product prices to include a 'Price Per Unit' calculation (e.g., '$2.50 / kg') alongside the total price. This calculation must be applied consistently across the Product List Page, Product Detail Page, and Cart. Which is the most appropriate and maintainable approach to implement this?
Show answer & explanation
Correct answer: C
Creating a single, reusable LWC for the specific task of formatting the price per unit is the best practice. This promotes code reuse, ensures consistency, and simplifies maintenance. If the formatting logic needs to change, it only needs to be updated in one place. This component can then be easily composed within the PLP, PDP, and Cart components. Formula fields are not ideal for display logic, and cloning standard components creates a significant maintenance burden.
- Question 5Advanced
Error Handling and Diagnostics · Governor Limit Troubleshooting
A storefront's checkout flow is failing intermittently with a
LimitException: Too many SOQL queries: 101. A review of the debug logs points to a custom extension in the pricing service that is being invoked for each cart line item during checkout. The extension calculates custom discounts by querying related Account and Contract records. What is the most effective way to resolve this governor limit error?Show answer & explanation
Correct answer: B
This scenario describes a classic governor limit issue where a query is placed inside a loop. The solution is to bulkify the code. The correct pattern is to iterate through the cart items first, collect all the unique IDs needed for the secondary query (e.g., Account IDs, Contract IDs) into a Set or List. Then, perform a single SOQL query outside the loop to fetch all necessary records at once. The results can be stored in a Map for efficient lookup back inside the loop. This prevents the SOQL query from executing for every single cart item.
- Question 6Intermediate
Data Management · Automation and Triggers
A developer needs to ensure that when a buyer's
Cartis activated, a customCart_Audit__crecord is created to log the cart details for reporting. This logic must execute regardless of how the cart is activated (e.g., via the UI, API, or another automated process). What is the most reliable way to implement this requirement?Show answer & explanation
Correct answer: B
Using a record-triggered flow (or an Apex trigger) on the
WebCartobject is the most robust and reliable solution. This ensures the audit logic is tied to the data layer, not the UI. The flow will execute whenever aWebCartrecord is updated to have a status of 'Active', regardless of whether the change was initiated by a user in the storefront, an API call, or another process, guaranteeing the audit record is always created. - Question 7Intermediate
Reference Implementations · Shipping Calculation
A business requires that shipping costs be calculated by a third-party logistics provider's API during checkout. The API requires the cart items' weight, dimensions, and the destination address. Which B2B Commerce reference implementation provides the correct interface to implement this external callout?
Show answer & explanation
Correct answer: C
The
ShippingRateProviderinterface is specifically designed for integrating external shipping calculation services. A developer would create an Apex class that implements this interface. ThecalculateShippingRatemethod within this class would receive the cart details, which can be used to construct the request to the third-party API. The method would then process the API's response and return the calculated shipping rates to the checkout flow. - Question 8Intermediate
Basic Lightning Web Component Development · Wire Service and Data Refresh
A developer is building a custom Lightning Web Component to display product details. To fetch the product data, the developer uses the
@wiredecorator with thegetRecordadapter fromlightning/uiRecordApi. The business has now requested that the component include a 'Refresh' button to manually refetch the latest product data from the server. How can the developer implement this refresh functionality?Show answer & explanation
Correct answer: B
When using the
@wiredecorator to call an Apex method, the correct way to programmatically refresh the data is to use therefreshApexfunction. You must import it from the@salesforce/apexmodule. The function takes the entirepropertythat was provisioned by the@wireservice (the object containingdataanderror) as its argument. Calling this function tells the Lightning Data Service to fetch fresh data from the server and re-provision the wired property. - Question 9Intermediate
Checkout Flow Development · LWC in Flows
A developer needs to create a custom checkout flow step that collects delivery instructions from the buyer. Which of the following components is essential for making a custom LWC available as a screen component within the Flow Builder?
Show answer & explanation
Correct answer: B
To make a Lightning Web Component available for use in a Flow screen, its metadata configuration file (
.js-meta.xml) must be updated. The developer needs to addlightning__FlowScreenwithin thesection and settrue. This configuration tells the Salesforce platform that the component is intended to be used within the Flow Builder canvas. - Question 10Advanced
Data Management · Data Migration Strategy
Case Study: 'Cascade Chemical Corp' Data Migration
Company Background: Cascade Chemical Corp is a large chemical supplier migrating its B2B operations to Salesforce B2B Commerce. They have a complex data structure in their legacy ERP system that needs to be imported into Salesforce.
Data Migration Requirements:
- Products: 50,000
Product2records with multiple images and specification documents stored in Salesforce CMS. - Buyer Accounts: 5,000
Accountrecords with relatedContacts. - Price Books: 200
Pricebook2records, each with thousands ofPricebookEntryrecords linking products to prices. - Entitlement Policies: A complex matrix where specific Buyer Accounts are entitled to purchase specific Product Categories from specific Catalogs.
- Data Relationships: The integrity of relationships between Accounts, Entitlement Policies, Catalogs, and Price Books is critical for the store to function correctly.
Technical Challenge: The implementation team needs to perform the initial data load efficiently and ensure all relationships are correctly established. The process must be repeatable for testing in different sandboxes before the production deployment. The team is considering various tools and methods for this complex data loading task.
Question: Given the complexity and inter-dependencies of the B2B Commerce data model, which of the following represents the most effective and reliable strategy for this data migration?
erDiagram BUYER_ACCOUNT ||--|{ CONTACT : has BUYER_ACCOUNT ||--o{ WEBSTORE_BUYER_GROUP : memberOf WEBSTORE_BUYER_GROUP ||--|{ ENTITLEMENT_POLICY : has ENTITLEMENT_POLICY ||--|{ PRODUCT_CATALOG : grantsAccessTo PRODUCT_CATALOG ||--|{ PRICEBOOK2 : uses PRODUCT2 ||--|{ PRICEBOOK_ENTRY : hasPriceIn PRICEBOOK2 ||--|{ PRICEBOOK_ENTRY : contains PRODUCT_CATEGORY ||--o{ PRODUCT2 : containsShow answer & explanation
Correct answer: C
For a complex, repeatable, and large-scale data migration, a dedicated ETL (Extract, Transform, Load) tool is the superior choice. Tools like MuleSoft or Salesforce Data Pipelines are designed to handle complex data relationships, transformations, and orchestration. They allow developers to build reusable data maps, automate the process of looking up parent record IDs, and provide robust error handling and logging. This approach is far more efficient, reliable, and easier to maintain for repeated runs in different environments compared to manual Data Loader processes or writing extensive custom Apex code.
- Products: 50,000
Ready for the real thing?
The full AP-202 simulator has every exam-style question, timed mode, and instant scoring.