+ Start a Discussion
sekhar 131sekhar 131 

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

Please solve this error message
VamsiVamsi
Hi Sekhar,

It seems that you are trying to insert a record with provided ID, that is impossible because record is created already.
Probably you need to update it - use update statement instead of insert.
In case if you are not sure if record exists - use upsert (it works as update for record with given id and as insert for record with missing id in general).
Here you can read more about upsert: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_database.htm#apex_System_Database_upsert_2

Please mark as best answer if the above helps ..!!