function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Saravana RavikumarSaravana Ravikumar 

I currently have a master detail relationship between order object and orderitem object . I want to create several orders from one order and then rearrange the orderitem records to different orders. Can I use Allow reparenting or junction object ?

SubratSubrat (Salesforce Developers) 
Hello saravana .

es, you can use either "Allow Reparenting" or a junction object to achieve the desired functionality of rearranging OrderItem records to different orders.

Allow Reparenting: If you enable the "Allow Reparenting" option on the master-detail relationship between the Order and OrderItem objects, it will allow you to change the parent Order for OrderItem records. This means you can move OrderItem records from one Order to another by simply updating the parent field.

Junction Object: Another approach is to introduce a junction object between Order and OrderItem. A junction object is a custom object that serves as a "bridge" between two objects, allowing for many-to-many relationships. In this case, you can create a junction object, let's say "OrderItemJunction," which would have a master-detail relationship with both the Order and OrderItem objects. This junction object would act as a container for the relationship between Orders and OrderItems.

With the junction object in place, you can create multiple OrderItemJunction records for each OrderItem you want to associate with different Orders. By updating the junction object records, you can effectively rearrange the OrderItem records across different Orders.

If this helps , please mark this as Best Answers.
Thank you.