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
VK86VK86 

Re-assign Child record to a different Master record

Hello all,

 

I have a custom object 'Invoice' which is a child to Account obj.

I have few invoice records (example: inv1, inv2, inv3,..) which are already assigned to an account (example: Acc1).

 

Now i want to assign these to another account (example: Acc2).

 

Any pointers how to achieve this is really appreciated.

 

Thanks,

VK

BeeddiskShahBeeddiskShah

You want to do this using code or data loading?

 

In case you want to update using data loader, you can download the records and in the column accountid, simply change the Id from Acc1 to Acc2 in the column and update the record.

super developersuper developer

When do you want to do

 

And do you want these childs need to be change aac1 to acc2 means(completely all childs of acc1 move to acc2.after that these childs not related to acc1).

1. For this better is put one deatiled page button in acc2. if we click on that button call vf page passing present accountid(ACC2).

 

In Vf page show the pick list with all accounts other than current account(acc2). select one account(this account(acc1) child records) will reassign to account(acc2) which we clicked.

 

2. Other Wise You want re assign for one invoice child to different account then also put button on invoice detailed page.  Pass invoice id to page display accounts (other than current assigneed account(acc1)). After selection account you can re assign account(acc2).

 

CLKCLK

run this code with ur account id's in system log.

 

Id accnt_1_id = ?;

Id accnt_2_id = ?;

 

List<Invoice> lstInvoice = [select id,account from Invoice where account =: accnt_1_id];

for(invoice oInvoice : lstInvoice)

       oInvoice.account = accnt_2_id;

update lstInvoice;

VK86VK86

Hello Beeddisk Shah,

 

We cannot update the Parent object id using data loader for a Master-detail relationship.

I will have to resort to using a custom button as suggested by others.

 

Thanks,

VK

VK86VK86

Hello Super developer,

 

I will add a custom button on the child record. That way, it will suffice my requirement.

I do not want all the child records of Acc1 to be assigned to Acc2 at one go. Instead i want only select child records to be reassigned.

 

Thanks,

VK

ChellappaChellappa

Did any of the above solution work.

I dont think any one would work.

 

Master Detail relationship cannot be Reassigned.

 

I tried executing the Apex approach mentioned , i got "System.SObjectException: Field is not writeable" error.

 

Please let me know whether it worked for anyone.

 

Regards,

Chellappa

Innovative DeveloperInnovative Developer

Hi Super developer,

 

I need help on webservices. Would you please help me.