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
Amit ChaudharyAmit Chaudhary 

Insert operation giving DML exception ?

This is the error . I have check field name correct , values are correct . then what would be reason ?

System.DmlException: Insert failed. First exception on row 0 with id a0E9000000pZuMyEAK; first error: INVALID_FIELD_FOR_INSERT_UPDATE, cannot specify Id in an insert call: [Id]
Error is in expression '{!genrate}' in component <apex:commandButton> in page genrate_invoice .
Cloud_forceCloud_force
i think you are trying to insert value for id field. id field is autogenerated by salesforce and is real only field.

thanks,
http://www.forcexplore.com/2014/07/using-controller-in-visualforce-page.html
Deepak Kumar ShyoranDeepak Kumar Shyoran
Please remove Id field from your records as you can't define Id for new records to be insert or if you want to modify some previous records then use update dml instead of insert.

Please mark my answer as a solution to your question if it solves your problem.
Jazz@SalesforceJazz@Salesforce
ID field is a system generated field. It is read only and you can not change it.
Ajit KumarAjit Kumar

whenever a record is inserted in salesforce, an Unique ID is generated for it. This ID field is read only, u cant insert/update it manually. So just remove the ID field in ur insert statement. It should work fine.

:)

Thank You