For storing application configurations and integration settings that need to be easily modified by administrators and deployed across environments, Custom Metadata Types are the preferred solution. Unlike Custom Settings (Options A and D), records within a Custom Metadata Type are considered metadata rather than data. This is a critical distinction for the development lifecycle because these records can be included in Change Sets or deployment packages. This eliminates the manual overhead and risk associated with re- creating configuration records in production after a sandbox deployment. In this scenario, UC needs to manage settings for two different payment processors. A Custom Metadata Type can be created with fields for API endpoints, merchant IDs, and security keys. An administrator can then create and edit the specific records for the "Individual" and "Corporate" processors directly in the Setup menu. Furthermore, Custom Metadata queries are efficient and do not count against standard SOQL governor limits in many contexts. While Custom Labels (Option B) are useful for translating text, they are not intended for complex, structured configuration data. Hierarchy Custom Settings are designed for user-specific overrides, which is not applicable here. Therefore, Custom Metadata provides the most robust, deployable, and administrator-friendly way to manage external service configurations.
PDII-JPN Exam Question 42
以下のコード スニペットを参照してください。 ジャワ public static void updateCreditMemo(String customerId, Decimal newAmount){ List<Credit_Memo__c> toUpdate = new List<Credit_Memo__c>(); for(Credit_Memo__c creditMemo : [Select Id, Name, Amount__c FROM Credit_Memo__c WHERE Customer_Id__c = :customerId LIMIT 50]) { creditMemo.Amount__c = newAmount; toUpdate.add(creditMemo); } データベースを更新します(toUpdate、false)。 } Salesforce環境にCredit_Memo__cというカスタムオブジェクトが存在します。新機能開発の一環として、開発者はApexトランザクション内でレコードセットが変更される際に競合状態が発生しないようにする必要があります。上記のApexコードにおいて、SOQL機能を使用してトランザクション内で競合状態が発生しないようにするには、クエリステートメントをどのように変更すればよいでしょうか?
Correct Answer: A
Co6mprehensive and Detailed 150 to 250 words of Explanation: To prevent race conditions in Salesforce, where two or more concurrent transactions attempt to update the same record simultaneously, a developer must implement record locking. In SOQL, this is achieved using the FOR UPDATE keyword. When a query includes the FOR UPDATE clause, the platform places an exclusive lock on the returned records for the duration of the transaction. If another process attempts to update these records or lock them with its own FOR UPDATE query, it will be forced to wait until the first transaction completes (commits or rolls back). If the lock is not released within 10 seconds, the second process will receive a QueryException. Option A is the correct syntax to ensure that the Credit_Memo__c records are "reserved" for the current logic, preventing other threads from interfering with the newAmount calculation or update. Option B (USING SCOPE) is used for filtering records based on predefined ownership scopes like "My Terrace." Options C and D (FOR REFERENCE and FOR VIEW) are used to update the "Last Referenced" or "Last Viewed" timestamps on records, respectively, and do not provide the row-level locking required to prevent data concurrency issues or race conditions.
PDII-JPN Exam Question 43
マイオポチュニティ.js JavaScript import { LightningElement, api, wire } from 'lwc'; import getOpportunities from '@salesforce/apex/OpportunityController.findMyOpportunities'; export default class MyOpportunities extends LightningElement { @api userId; @wire(getOpportunities, {oppOwner: '$userId'}) opportunities; } OpportunityController.cls Java public with sharing class OpportunityController { @AuraEnabled public static List<Opportunity> findMyOpportunities(Id oppOwner) { return [ SELECT Id, Name, StageName, Amount FROM Opportunity WHERE OwnerId = :oppOwner ]; } } 開発者がLightning Webコンポーネントで問題を抱えています。このコンポーネントは、現在ログインしているユーザーが所有する商談に関する情報を表示する必要があります。コンポーネントをレンダリングすると、「データ取得エラー」というメッセージが表示されます。これを接続可能にするには、Apexメソッドでどのアクションを実行する必要がありますか?
Correct Answer: C
To use the @wire service in a Lightning Web Component (LWC) to retrieve data from an Apex method, the Apex method must be marked as cacheable. In the provided OpportunityController class, the findMyOpportunities method is annotated with @AuraEnabled, but it lacks the mandatory cacheable=true property. The @wire service is part of the Lightning Data Service (LDS) reactive framework. Salesforce requires wireable methods to be cacheable to improve performance and ensure that data can be stored in the client-side cache. Without (cacheable=true), the @wire decorator will fail to execute, resulting in the "Error retrieving data" message or a similar runtime failure. Option C is the correct fix: the developer must update the annotation to @AuraEnabled(cacheable=true). Option A (Continuation) is only for long-running external callouts. Option B (without sharing) might affect visibility but isn't a requirement for the wire service itself. Option D (OWD) affects whether records are visible based on security, but the technical failure described is rooted in the component-to-Apex binding requirement. Once marked as cacheable, the LDS can properly manage the data lifecycle for the component.
When building Apex controllers for Aura Components (or Lightning Web Components), any method annotated with @AuraEnabled must be defined as static. The snippet provided defines the method getStringArray() as an instance method (public List<String>...) rather than a static method (public static List<String>...). The Lightning Component framework does not instantiate an object of the Apex class; instead, it calls the method statically. If the method is not static, the framework cannot locate or execute it, resulting in an error. While global was required in older versions or for managed packages, public is sufficient for code within the same namespace. Apex handles the serialization of standard types like Lists automatically, so manual JSON serialization is not required.
When an external application needs to request data from Salesforce, you must expose an endpoint. Since the requirement specifically mentions JSON format and a native mobile app (iOS), an Apex REST web service (Option D) is the optimal choice. REST (Representational State Transfer) is the industry-standard architecture for mobile-to-cloud integrations because it is lightweight, uses standard HTTP methods, and natively supports JSON. By using the @RestResource and @HttpGet annotations in an Apex class, a developer can create a custom endpoint that performs complex logic, such as querying multiple objects (Accounts, Orders, Line Items), and returns a single, consolidated JSON response. This is far more efficient than the standard REST API if the mobile app would otherwise need to make multiple sequential calls to gather the same information. Options B and C are incorrect because "callouts" are used when Salesforce requests data from an external system, not the other way around. Option A (SOAP) is a heavier, XML-based protocol that is less efficient for mobile development and does not use the JSON format natively. Therefore, a custom Apex REST service provides the best performance and flexibility for mobile integrations.