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

Overriding clone with the same page as new custom object Problem!

Hey there,


I have created a VF page with extension that will re-direct the user to a visualforce page with the correct tab open after creating a new record. I tried putting that same page onto the clone button and although it autofilled the correct fields, upon attempting to save I was left with this:


System.DmlException: Insert failed. First exception on row 0 with id a0LN0000000OsBEMA0; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]

Error is in expression '{!SaveFactFinder}' in component <apex:commandButton> in page factfinderext



Class.extSaveButton.saveFactFinder: line 11, column 1



Am I able to do it like this or do I have to create an entirely different VF page and extension?


Thank you,



Hi Mikie, 

There can be two possible reason for this, 

1. You are trying to Insert the Existing Id and making a New Record. 

You have to allow Salesforce to create a new Id for the Newly Cloned record. 


2. You are trying to Insert record in a For loop. 

Remove the DML statement from the For loop. 

See the links below for further information,