A developer deployed a trigger to update the status__c of Assets related to an Account when the Account's status changes and a nightly integration that updates Accounts in bulk has started to fail with limit failures.
What should the developer change about the code to address the failure while still having the code update all of the Assets correctly?
A developer needs to implement a custom SOAP Web Service that is used by an external Web Application. The developer chooses to include helper methods that are not used by the Web Application in the implementation of the Web Service Class.
Which code segment shows the correct declaration of the class and methods?
A)
B)
C)
D)
Managers at Universal Containers want to ensure that only decommissioned containers are able to be deleted in the system. To meet the business requirement a Salesforce developer adds "Decommissioned'' as a picklist value for the status__c custom field within the Container__c object.
Which two approaches could a developer use to enforce only Container records with a status of "Decommissioned'' can be deleted?
Choose 2 answers
To enforce that only Container__c records with a status of 'Decommissioned' can be deleted, we need to prevent deletion of records unless they meet this criteria.
Possible Approaches:
Option A: Apex Trigger
Correct.
An Apex before delete trigger can be written to check the Status__c field of each record being deleted.
If the status is not 'Decommissioned,' the trigger can add an error to prevent deletion.
trigger PreventContainerDeletion on Container__c (before delete) {
for (Container__c container : Trigger.old) {
if (container.Status__c != 'Decommissioned') {
container.addError('Only decommissioned containers can be deleted.');
}
}
}
A before delete flow can be created to check the Status__c field.
If the status is not 'Decommissioned,' the flow can prevent deletion by adding an error.
Validation rules fire on insert and update operations, not on delete.
They cannot prevent deletion of records.
After delete flows cannot prevent a deletion because the record has already been deleted.
Only before delete flows can prevent deletion.
Option D: Before Record-Triggered Flow
Correct.
Add an Error to Stop a Record from Being Deleted
Incorrect Options:
Option B: Validation Rule
Incorrect.
Validation Rule Considerations
Option C: After Record-Triggered Flow
Incorrect.
Conclusion:
To enforce the deletion restriction, the developer can use an Apex trigger or a before delete record-triggered flow, which are options A and D.
A developer creates a custom exception as shown below:
public class ParityException extends Exception. {}
What are two ways the developer can fire the exception in Apex? Choose 2 answers
To fire an exception in Apex, the developer must use the throw statement along with an instance of the exception.
Option A: throw new ParityException();
Correct Way.
Creates a new instance of ParityException with no message and throws it.
Syntax is correct for throwing an exception.
Option C: throw new ParityException('parity does not match');
Correct Way.
Creates a new instance of ParityException with a custom message and throws it.
The exception class inherits from Exception, which allows passing a message to the constructor.
Options Not Correct:
Option B: new ParityException('parity does not match');
Incorrect.
This statement creates a new instance of ParityException but does not throw it.
Without the throw keyword, the exception is not fired.
Option D: new ParityException();
Incorrect.
Similar to Option B, this creates a new instance but does not throw it.
The exception will not affect the flow unless it is thrown.
Conclusion:
The two ways the developer can fire the exception are:
Option A: throw new ParityException();
Option C: throw new ParityException('parity does not match');
Both use the throw statement to fire the exception.
What are three ways for a developer to execute tests in an org?
Choose 3 answers
There are several ways to execute tests in a Salesforce org:
Option A: Setup Menu
Valid Method.
Tests can be run from the Salesforce Setup menu under Apex Test Execution.
Allows selecting and running test classes and methods.
The Tooling API allows programmatic execution of Apex tests.
Useful for integrating with external tools or CI/CD pipelines.
Salesforce DX (SFDX) CLI allows running tests via command line.
Commands like sfdx force:apex:test:run can execute tests.
The Metadata API is used for deploying and retrieving metadata (like Apex classes).
It is not used to execute tests directly.
The Bulk API is used for loading or querying large volumes of data.
It is not related to executing Apex tests.
Running Apex Tests in Salesforce Setup
Option B: Tooling API
Valid Method.
Option D: Salesforce DX
Valid Method.
Salesforce CLI Command Reference
Incorrect Options:
Option C: Metadata API
Not Used for Executing Tests.
Option E: Bulk API
Not Used for Executing Tests.
Conclusion:
The three ways a developer can execute tests are A (Setup Menu), B (Tooling API), and D (Salesforce DX).