Salesforce PDII Online Practice
Questions and Exam Preparation
PDII Exam Details
Exam Code
:PDII
Exam Name
:Salesforce Certified Platform Developer II (Plat-Dev-301)
Certification
:Salesforce Certifications
Vendor
:Salesforce
Total Questions
:445 Q&As
Last Updated
:Jun 19, 2026
Salesforce PDII Online Questions &
Answers
Question 331:
A developer created a Lightning web component that uses a lightning-record-edit-form to collect information about Leads. Users complain that they only see one error message at a time when they save a Lead record.
Which best practice should the developer use to perform the validations, and allow more than one error message to be displayed simultaneously?
A. Custom validation rules B. Process Builder C. Client-side validation D. Apex REST
C. Client-side validation
Explanation
When using lightning-record-edit-form, server-side validation rules (Option A) typically return errors one at a time as the database engine encounters them, or as a single combined toast message that can be difficult to parse. To provide a superior user experience where multiple fields are validated simultaneously before the data even reaches the server, the developer should implement Client-side validation (Option C) .
In the component's JavaScript controller, the developer can intercept the onsubmit event. By iterating through all the lightning-input-field or standard lightning-input elements, the developer can programmatically check for various conditions (e.g., custom regex patterns, conditional logic between fields, or range checks). Each field can then be marked with a custom error message using the reportValidity() or setCustomValidity() methods. This allows the UI to highlight all invalid fields at once, providing immediate, comprehensive feedback to the user. This approach reduces unnecessary server round-trips and ensures that the user can correct all issues in a single pass before successfully submitting the record.
Question 332:
When calling a RESTful web service, the developer must implement two-way SSL authentication to enhance security. The Salesforce admin has generated a self-sign certificate within Salesforce with a unique name of "ERPSecCertificate".
Which method must the developer implement in order to sign the HTTP request with the certificate?
A. req.setHeader('certificate', 'ERPSecCertificate'); B. req.setSecure('ERPSecCertificare)'; C. req.setClientCertificateName('ERPSecCertificate'); D. req.setSecureCertificate( 'ERPSecCertificate');
C. req.setClientCertificateName('ERPSecCertificate');
Question 333:
A developer is trying to decide between creating a Visualforce component or a Lightning component for a custom screen. Which functionality consideration impacts the final decision?
A. Does the screen need to be accessible from the Lightning Experience UI? B. Will the screen make use of a JavaScript framework? C. Does the screen need to be rendered as a PDF? D. Will the screen be accessed via a mobile app?
C. Does the screen need to be rendered as a PDF?
Question 334:
A user receives the generic "An internal server error has occurred" while interacting with a custom Lightning Component. What should the developer do to ensure a more meaningful message?
A. Use an AuraHandledException in a try/catch block. B. Use ProcessBuilder to catch the error. C. Add an onerror event handler to the tag. D. Add an error-view component to the markup.
A. Use an AuraHandledException in a try/catch block.
Question 335:
A company needs to automatically delete sensitive information after 7 years. This could delete almost a million records every day. How can this be achieved?
A. Schedule an @future process to Query records older than 7 years, and then recursively invoke itself in 1,000 record batches to delete them. B. Perform a SOSL statement to find records older than 7 years, and then delete the entire result set. C. Use aggregate functions to query for records older than 7 years, and then delete the AggregateResult objects. D. Schedule a batch Apex process to run every day that Queries and deletes records older than 7 years.
D. Schedule a batch Apex process to run every day that Queries and deletes records older than 7 years.
Explanation
When dealing with large-scale data maintenance, such as deleting a million records daily, Batch Apex is the most robust and scalable solution provided by the Salesforce platform. Batch Apex is specifically designed for processing high volumes of records by breaking the total record set into manageable "batches" (defaulting to 200 records per batch). This prevents the transaction from hitting platform governor limits, such as the limit on the total number of DML statements or the maximum number of records processed in a single transaction. By scheduling a Batch class, the system handles the heavy lifting asynchronously, ensuring that org performance is not negatively impacted during peak hours.
Other options are unsuitable for this scale. Using @future methods for recursive processing is a poor practice because Salesforce prohibits calling a future method from another future method, and it is difficult to monitor or manage the execution flow. Aggregate functions and AggregateResult o1bjects are used for calculations and data grouping, not for DML operations like deletion. Similarly, SOSL is optimized for text-based searching across multiple objects and returns a limited number of results, making it inappropriate for an exhaustive cleanup of a million records. Batch Apex allows for the use of a QueryLocator, which can handle up to 50 million records, providing the necessary throughput for this high- volume requirement.
Question 336:
Universal Containers stores user preferences in a Hierarchy Custom Setting, User_Prefs__c, with a checkbox field, Show_Help__c. Company-level defaults are stored at the organizational level, but may be overridden at the user level. If a user has not overridden preferences, then the defaults should be used.
How should the Show_Help__c preference be retrieved for the current user?
A. Boolean show = User_Prefs__c.getInstance().Show_Help__c; B. Boolean show = User_Prefs__c.getValues().Show_Help__c; C. Boolean show = User_Prefs__c.getValues(UserInfo.getUserId()).Show_Help__c; D. Boolean show = User_Prefs__c.Show_Help__c;
A. Boolean show = User_Prefs__c.getInstance().Show_Help__c;
Which use case can only be performed by using asynchronous Apex?
A. Scheduling a batch process to complete in the future B. Processing high volumes of records C. Updating a record after the completion of an insert D. Calling a web service from an Apex trigger
D. Calling a web service from an Apex trigger
Explanation
Salesforce enforces a strict architectural boundary regarding database transactions and external communications. When an Apex trigger executes, it is part of a synchronous database transaction. If the platform allowed a synchronous callout (a web service call) directly from a trigger, the database transaction-- including all active record locks--would have to remain open while waiting for the external system to respond. This could lead to severe performance degradation and hit the "Concurrent Request" limit.
Consequently, calling a web service from an Apex trigger (Option D) must be handled asynchronously. A developer must hand off the callout logic to an @future(callout=true) method, a Queueable class, or a Platform Event. This allows the trigger to finish its work and commit the database transaction immediately, while the callout runs in its own separate background process with its own set of governor limits.
Option B is incorrect because a standard synchronous query can retrieve up to 50,000 records. Option A is initiate a process, even if the process itself incorrect because System.scheduleBatch is a synchronous call to runs later. Option C is incorrect because record updates can be handled synchronously in an after insert trigger context.
Question 338:
A company has a custom object, Order__c, that has a custom picklist field, Status__c, with values of New, In Progress, or Fulfilled, and a lookup field, Contact__c, to Contact.
Which SOQL query will return a unique list of all the Contact records that have no Fulfilled Orders?
A. SELECT Contact__cFROM Order__cWHERE Id NOT IN (SELECT Id FROM Order__c WHERE Status__c = 'Fulfilled') B. SELECT IdFROM ContactWHERE Id NOT IN (SELECT Id FROM Order__c WHERE Status__c = 'Fulfilled') C. SELECT Contact__cFROM Order__cWHERE Status__c <> 'Fulfilled' D. SELECT IdFROM ContactWHERE Id NOT IN (SELECT Contact__cFROM Order__cWHERE Status__c = 'Fulfilled')
D. SELECT IdFROM ContactWHERE Id NOT IN (SELECT Contact__cFROM Order__cWHERE Status__c = 'Fulfilled')
Question 339:
What is the best practice to initialize a Visualforce page in a test class?
A. Use Test.setCurrentpage,MyTestPage; B. Use Test.currentpage, getParameter, put (MyTestPage); C. Use Test, setCurrentPage(Page.MyTestPage); D. Use controller,currentPage, setPage (MyTestPage);
C. Use Test, setCurrentPage(Page.MyTestPage);
Explanation
When writing unit tests for Visualforce controllers, the code must be executed within a simulated "Page Context." Without setting this context, methods that rely on ApexPages.currentPage() (such as retrieving URL parameters or adding page messages) will fail with a null pointer exception.
The standard and correct syntax to set this context is Test.setCurrentPage(Page.MyTestPage); (Option C) . The Page reference (e.g., Page.MyTestPage) is a special system variable that represents the URL of the Visualforce page. Passing this into Test.setCurrentPage() tells the Apex testing engine: "Act as if the browser is currently looking at this specific page."
Options A and D use incorrect syntax that does not exist in the Apex language. Option B is a secondary step; you use .getParameters().put() after setting the current page to simulate passing specific values (like an ID) in the URL. By properly initializing the page context using Option C, the developer ensures that the controller's logic--including constructors and action methods--can be tested accurately and reliably.
Question 340:
During the Visualforce Page execution, what step follows immediately after "Evaluate constructors on controller and extensions"?
A. Create the view state B. Evaluate constructors, extensions, and expression on attribute definitions on any custom components present C. Evaluate expressions, <apex:page> attribute actions, and other method calls (getters/setters) on main page D. Send HTML to Browser
B. Evaluate constructors, extensions, and expression on attribute definitions on any custom components present
Nowadays, the certification exams become more and more important and required by more and more
enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare
for the exam in a short time with less efforts? How to get a ideal result and how to find the
most reliable resources? Here on Vcedump.com, you will find all the answers.
Vcedump.com provide not only Salesforce exam questions,
answers and explanations but also complete assistance on your exam preparation and certification
application. If you are confused on your PDII exam preparations
and Salesforce certification application, do not hesitate to visit our
Vcedump.com to find your solutions here.