Fix ‘Error: Field is not writeable’ for Master-Detail relationship

An error “Error: Field is not writeable” will occur if you try modifying a Master-Detail relationship field in Salesforce Apex code. So how can we fix it?

Maybe using the clone method to insert&delete is the only way, as the following apex code :

Reference:Apex System SObject Clone

Enjoy It!

Related Post

Use subquery in SOQL Salesforce allows us to use subquery in SOQL. The following soql is a sample, shows how to filter out Parent Records that don't have a related child with subquery. And subquery also works in Related(Lookup) Objects, e.g.
Salesforce Dev Tools for Chrome™ Salesforce Dev Tools for Chrome™ is a Chrome extension helping developers do the below things: ・Export definition of objects to Excel file. ・Show / Hide object API name on object detail page by 1 Click. ・Quick generate test data Apex Code for Unit Test. ・Quick access to new...
Salesforce reRender dose not work with rendered at... Salesforce reRender will not work, if we're going to hide reRender target with rendered attribute of itself, as the following sample code. In my opinion, reRender will reset the target DOM Node but...
How to access static resources from Apex, Visualfo... In Apex Normal file (with soql) Normal file (with PageReference.getContent) Zip file (with PageReference.getContent) ※Zip file can not be accessed by soql.

Post Tagged with , , ,