開発者が、Apex クラスを使用するカスタム注文管理アプリケーションを作成しました。注文は、Order オブジェクトと、Order と主従関係を持つ OrderItem オブジェクトによって表されます。注文処理中に、注文が複数の注文に分割される場合があります。
コードで一部の既存の OrderItem レコードを新しい Order レコードに移動できるようにするには、開発者は何をする必要がありますか?
正解:D
The developer should select the Allow reparenting option on the master-detail relationship between Order and OrderItem. This option enables the developer to change the parent record of a child record in a master-detail relationship, which is also known as reparenting. By default, reparenting is not allowed in master-detail relationships, because the child record inherits the sharing and security settings of its parent record. However, in some cases, such as splitting an order into multiple orders, reparenting may be necessary to move some existing OrderItem records to a new Order record. The developer can use the Apex Data Manipulation Language (DML) statements, such as update or upsert, to change the parent record of the OrderItem records.
Changing the master-detail relationship to an external lookup relationship is not a valid option, because external lookup relationships are only available for external objects, which are objects that map to data stored outside Salesforce. Adding without sharing to the Apex class declaration is not a relevant option, because it only affects the sharing rules that apply to the Apex class, not the relationship between the objects. Creating a junction object between OrderItem and Order is not a suitable option, because it would create a many-to-many relationship between the objects, which is not the desired outcome.
References: Master-Detail Relationships, Reparent Records in Master-Detail Relationships, Prepare for Your Salesforce Platform Developer I Credential