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
Developer.mikie.Apex.StudentDeveloper.mikie.Apex.Student 

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,

 

Mikie

Ashish_SFDCAshish_SFDC
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. 

Or,

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, 

https://developer.salesforce.com/forums/ForumsMain?id=906F00000008wswIAA

https://success.salesforce.com/answers?id=90630000000gqsLAAQ


Regards,
Ashish