Salesforce Certified Platform Developer II Plat-Dev-301 Exam Questions

Page: 1 / 14
Total 161 questions
Question 1

Refer to the test method below:

Java

@isTest

static void testAccountUpdate() {

Account acct = new Account(Name = 'Test');

acct.Integration_Updated__c = false;

insert acct;

CalloutUtil.sendAccountUpdate(acct.Id);

Account acctAfter = [SELECT Id, Integration_Updated__c FROM Account WHERE Id = :acct.Id][0];

System.assert(true, acctAfter.Integration_Updated__c);

}

The test method calls a web service that updates an external system with Account information and sets the Account's Integration_Updated__c checkbox to True when it completes. The test fails to execute and exits with an error: "Methods defined as TestMethod do not support Web service callouts." What is the optimal way to fix this?



Answer : D

Salesforce enforces a strict restriction: Actual network callouts are prohibited during unit tests. This is to ensure that tests are deterministic, fast, and do not rely on the availability or state of external third-party systems. When the testing engine encounters a System.Http.send() or a web service call without a mock, it throws the error: 'Methods defined as TestMethod do no1t support Web servi2ce callouts.'34

To resolve this, the developer must provide a Mock Implementation. By using Test.setMock() (Option D), the developer instructs the Apex runtime to intercept any callouts and return a pre-defined response instead of attempting a real connection. The mock class5 must implement either the HttpCalloutMock interface (for REST) or the WebServiceMock interface (for SOAP).

Furthermore, the call to the mock and the callout method should be wrapped in Test.startTest() and Test.stopTest().6

Test.startTest(): Resets governor limits, providing a fresh context for the specific logic being tested.7

Test.stopTest(): Forces any asynchronous processing (often used in cal8louts, such as @future or Queueable) to complete before the next line of code executes.

In the provided code, Test.setMock must be called before CalloutUtil.sendAccountUpdate for the platform to know which mock to use. Once Test.stopTest() is reached, the mock response is processed, the checkbox is updated, and the subsequent SOQL query and assertion will correctly see the updated data. Option A is a poor practice because it skips the logic entirely, resulting in 0% code coverage for the integration logic.


Question 2

A developer is writing a Lightning Web component that queries accounts in the system and presents a lightning-datatable with the results. The users want to be able to filter the results based on up to five fields, that will vary according to their selections when running the page. Which feature of Apex code is required to facilitate this solution?



Answer : D

When the structure of a query---such as the number of filters or the specific fields in the WHERE clause---is not known at compile-time and must be determined at runtime based on user input, 'Dynamic SOQL' is the required feature. Unlike static SOQL, which is written directly in the Apex code and validated during compilation, Dynamic SOQL allows a developer to construct a query as a string.14

In this scenario, the user might choose to filter by 'Industry' and 'AnnualRevenue' in one session, but only by 'BillingCity' in another. By using Database.query(queryString), the developer can programmatically append WHERE clauses to the base query string based on the selections made in the Lightning Web component. This provides the flexibility to handle the varying number of fields (up to five) without writing dozens of different static queries or complex 'if-else' blocks that are difficult to maintain.

While describeSObjects() (Option A) can be used to get metadata about the fields, it doesn't execute the query. SOSL (Option C) is for text-based searching across multiple objects and is less efficient for specific field filtering on a single object. The REST API (Option B) is an external interface and not a feature of Apex used to solve internal filtering logic within an LWC controller. Therefore, Dynamic SOQL is the standard tool for building highly flexible, user-driven search interfaces on the platform.

==========


Question 3

A developer needs to implement a system audit feature that allows users, assigned to a custom profile named "Auditors", to perform searches against the historical records in the Account object. The developer must ensure the search is able to return history records that are between 6 and 12 months old. Given the code below, which select statement should be inserted as a valid way to retrieve the Account History records?4445

Java

Date initialDate = System.Today().addMonths(-12);

Date endDate = System.Today().addMonths(-6);

// Insert SELECT statement here



Answer : C

To query history records for a standard object like Account, the developer must use the correct API name, which is AccountHistory (not Account_History). When filtering for a range of dates, SOQL provides the BETWEEN operator, which makes the query cleaner and more readable. Option C uses both the correct object name and the BETWEEN syntax, making it the most efficient solution.

In SOQL, CreatedDate BETWEEN :initialDate AND :endDate is shorthand for CreatedDate >= :initialDate AND CreatedDate <= :endDate. In the provided code, initialDate is 12 months ago (the older date) and endDate is 6 months ago (the more recent date). Therefore, the range correctly captures records between those two timestamps.

Option A and B use an incorrect object name (Account_History). Option D uses the incorrect comparison operator => (the correct operator is >=). Furthermore, Option C follows the best practice for date range queries in Apex by using bind variables with the standard AccountHistory object, ensuring the 'Auditors' profile can retrieve the necessary historical data within the platform's audit and security constraints.

==========


Question 4

A company has reference data stored in multiple custom metadata records that represent default information and delete behavior for certain geographic regions. When a contact is inserted, the default information should be set on the contact. Additionally, if a user attempts to delete a contact that belongs to a flagged region, the user must get an error message. Depending on company personnel resources, what are two ways to automate this?16



Answer : B, D

Comprehensi22ve and Detailed 150 to 250 words of

This requirement involves two different automation triggers: record creation (insert) and record deletion (delete). To handle these events, Salesforce provides both declarative and programmatic options.

Flow Builder (Option B) is the preferred declarative tool. Record-Triggered Flows can be configured to run 'Before' a record is saved to handle the default value assignment upon insertion. They can also be configured to run when a record is deleted. Using the 'Custom Error' element within a Flow, an administrator can easily block a deletion and present a user-friendly error message if the contact belongs to a flagged region.

Apex Triggers (Option D) are the programmatic equivalent. A developer can write a before insert trigger to perform the metadata lookup and set field defaults, and a before delete trigger to check the region and call addError() on the record to prevent the deletion.

Options A (Remote Action) and C (Invocable Method) are not standalone automation triggers. A Remote Action is for JavaScript-to-Apex communication in Visualforce, and an Invocable Method is a piece of code called by another tool like a Flow or Strategy Builder. Therefore, Flow and Triggers are the two primary mechanisms to satisfy both the insertion and deletion requirements.

==========


Question 5

Which three actions must be completed in a Lightning web component for a JavaScript file in a static resource to be loaded?



Answer : A, B, C

To include an external JavaScript library in a Lightning Web Component (LWC), developers must follow a specific security and loading protocol dictated by the Lightning Locker or LWC Security. Standard HTML <script> tags (Option D) are not permitted in LWC templates for security reasons.

The correct process involves three steps:

Import the method from the platformResourceLoader (Option C): The developer must import the loadScript (for JS) or loadStyle (for CSS) function from the lightning/platformResourceLoader module.

Import the static resource (Option B): The developer must import the URL of the static resource using the @salesforce/resourceUrl/resourceName syntax.

Call loadScript (Option A): Inside a lifecycle hook (typically renderedCallback), the developer calls loadScript(this, this.myResourceUrl). This function returns a Promise, allowing the developer to perform initialization logic once the library is fully loaded and ready for use.

Option E is incorrect because LWC handles the loading and execution within the framework's security context; manually appending elements to the DOM is not the standard or safe way to load resources. This three-step process ensures that the external code is loaded asynchronously and safely within the component's namespace.

==========


Question 6

Universal Containers is using a custom Salesforce application to manage customer support cases. The support team needs to collaborate with external partners to resolve certain cases. However, they want to control the visibility and access to the cases shared with the external partners. Which Salesforce feature can help achieve this requirement?



Answer : B

28

When dealing with External Users (Community/Experience Cloud users), standard sharing mechanisms like Role Hierarchies o29ften do not apply, especially for high-volume Customer Community licenses which do not use the Role Hierarchy at all.

Sharing Sets (Option B) are specifically designed to grant external users access to records associated with their Account or Contact. A Sharing Set allows an administrator to define a simple mapping: for example, 'Grant access to Cases where the Case's Account matches the User's Account.' This is the most efficient and scalable way to provide external partners visibility into records relevant to them without using complex Apex code.

While Apex managed sharing (Option A) could technically work, it is much more complex to maintain and is only available for 'Customer Community Plus' or 'Partner' licenses. Criteria-based sharing rules (Option D) are typically used for internal users or broad groups, not for granular, account-specific access for individual external partners. Sharing Sets provide a high-performance, declarative solution for controlling external record visibility.


Question 7

A software company uses a custom object, Defect__c, to track defects in their software. Defect__c has organization-wide defaults set to private. Each Defect__c has a related list of Reviewer__c records, each with a lookup field to User that is used to indicate that the User will review the Defect__c. What should be used to give the User on the Reviewer__c record read only access to the Defect__c record on the Reviewer__c record?34



Answer : D

Comprehensive and Detailed 150 to 250 words 13of 14

In a Private sharing model, access is strictly limited to owners and those grant15ed access through specific sharing mechanisms. Here, the requirement is to grant access based on a User lookup field residing on a child record (Reviewer__c) to the parent record (Defect__c).

Criteria-based sharing rules (B) are ineffective here because they can only evaluate fields on the record being shared (Defect__c) and cannot 'look down' at values in related child records to determine access. 'View All' (A) is too broad as it would grant the user access to every defect in the system, violating the private security model.

Apex managed sharing (D) is the correct choice. Because the relationship between the assigned reviewer and the defect is dynamic and based on a separate object, a developer can write an Apex trigger on the Reviewer__c object. When a reviewer record is created or updated, the trigger programmatically inserts a record into the Defect__Share table, granting 'Read' access to the User specified in the lookup field. This provides the precision required to ensure that only the designated reviewers can see specific defects, maintaining the integrity of the Private OWD while automating the necessary exceptions.

==========


Page:    1 / 14   
Total 161 questions