16 The optimal architectural ap17proach for complex logic on a single object is to use a single trigger per object that delegates responsibilities to a helper class. This requirement involves two distinct types of logic: field manipulation (uppercase names) and cross-record updates (ensuring only one primary contact). In Salesforce, Before triggers are ideal for updating fields on the record that initiated the trigger, as the changes are saved to the database without an additional DML statement. Therefore, converting the LastName to uppercase should occur in a before update and before insert context. Conversely, the "Is Primary" logic requires updating other records (de-selecting other contacts on the same account). This must happen in an After trigger context to ensure the primary record has been successfully updated and to avoid recursion or conflicts with the initial save. Option D is the best practice because it follows the "One Trigger Per Object" design pattern. By using a single trigger with multiple context variables (isBefore, isAfter, isUpdate), the developer can cleanly route the "Last Name" logic to a before-save helper and the "Is Primary" cross-record update logic to an after-save helper. This centralized control prevents multiple triggers from firing in an unpredictable order and simplifies maintenance and debugging.
The requirement is to perform a callout when a record is inserted. Because Salesforce prohibits synchronous callouts after DML operations in the same transaction, this must be handled asynchronously. Queueable Apex (Option C) is the optimal choice for this integration. When an Account is inserted, a trigger captures the ID and enqueues a Queueable job. Queueable is superior to Future methods (Option D) because it supports complex data types (not just primitives), allows for job chaining, and provides a Job ID that can be used for monitoring via AsyncApexJob. Before-Save Flows (Option A) cannot directly perform callouts, and while they can trigger asynchronous paths, the programmatic control offered by a Trigger-to-Queueable pattern is more robust for complex third- party integrations. Batch Apex (Option B) is designed for bulk processing of existing records and is "overkill" for a real-time, record-by-record trigger requirement. By using a Trigger with Queueable, the developer ensures the address validation happens nearly in real-time without blocking the user's initial save transaction or hitting concurrent request limits.
When managing trigger logic that needs to be conditionally bypassed (often called a "Trigger Kill Switch"), using Hierarchy Custom Settings (Option D) is the best practice for scalability and maintainability. A developer can create a Hierarchy Custom Setting named Trigger_Settings__c with a checkbox field Disable_Opportunity_Trigger__c. In the Apex trigger, the code should first check this setting: if (Trigger_Settings__c.getInstance().Disable_Opportunity_Trigger__c) return; Because it is a hierarchy setting, an administrator can enable this checkbox specifically for the User or Profile performing the data load without affecting the daily operations of other sales reps. Once the data load is complete, the setting can be toggled off. This approach is "extendable" because it doesn't require hardcoding IDs (Option A), which change between environments (Sandbox vs. Production). Option C (List Custom Settings) is less flexible because it doesn't support the Profile-to-User hierarchy. Option B (Validation Rules) would stop the record creation but would result in a DML error in the trigger, potentially failing the entire data load transaction rather than simply skipping the logic. Hierarchy Custom Settings provide a clean, metadata-driven way to control execution flow across different user contexts.
To achieve a responsive layout in Salesforce Aura components, the lightning:layout and lightning:layoutItem components utilize a 12-column grid system. The size attribute defines the default behavior, which targets the smallest devices (mobile). In the original code, size="12" is applied to all three items. Since each item occupies the full 12 columns, they stack vertically in three rows. To meet Requirement 2 (displaying in a single row for tablets and desktops), the three items must share the 12-column horizontal space. Mathematically, $12 \div 3 = 4$. Therefore, each item must be assigned a size of 4 for larger screen breakpoints. Option D is the correct implementation. It maintains size="12" for mobile (Requirement 1) and sets mediumDeviceSize (tablets) and largeDeviceSize (desktops) to 4. This ensures that on any screen larger than a phone, the three items will sit side-by-side in a single row. Option A is incorrect because mediumDeviceSize="6" would only allow two items per row ($6 + 6 = 12$), forcing the third item to a second row. Option C is incomplete as it only specifies the largeDeviceSize, potentially leaving tablets in a stacked configuration. Option D follows the best practice of explicitly defining the span for all relevant device categories to ensure a consistent user experience.
PDII-JPN Exam Question 60
開発者は、次の HTML スニペットを使用して、sObject Lightning ページに存在する再利用可能な Aura コンポーネントを開発しています。 HTML <aura:component implements="force:hasRecordId,flexipage:availableForAllPageTypes"> <div>こんにちは!</div> </aura:component> 追加のテスト カバレッジを必要とせずに、コンポーネントのコントローラが sObject が存在する Lightning ページのコンテキストを取得するにはどうすればよいでしょうか?
Correct Answer: D
In Aura components, Salesforce provides specific interfaces that "inject" context into the component automatically. The developer is already using force:hasRecordId, which automatically populates a recordId attribute with the ID of the current record. To get the API Name of the sObject (e.g., "Account" or "Contact") without writing Apex code or requiring manual configuration in the App Builder, the developer should implement force:hasSObjectName (Option D). When this interface is added to the implements attribute, the framework automatically provides an attribute named sObjectName to the component. This is the most efficient solution because: * It is purely declarative and handled by the Lightning framework. * It requires zero Apex code, meaning there is no need for additional unit tests or code coverage (satisfying the requirement "without requiring additional test coverage"). * It makes the component truly reusable; you can drop it on an Account page, a Contact page, or any custom object page, and it will immediately know which object it is currently displaying. Options A and B require manual configuration or hardcoding, which reduces reusability. Option C requires an Apex call, which adds complexity and necessitates writing test classes for coverage.