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
Murthy vvrMurthy vvr 

Can we delete a record using external Id

I want to delete a record using its external id.

example :

Opportunity opt = new Opportunity();
opt.External_Id__c = ''external id of record'';
delete opt;

is it possible ?

When I do like this getting "System.ListException: Missing id at index: 0" exception.


Thanks in Advance,
Murthy VVR

Best Answer chosen by Murthy vvr
Vinita_SFDCVinita_SFDC
Hello,

Please refer following thread for possible workaround:

http://salesforce.stackexchange.com/questions/27812/mass-delete-custom-object-records-using-external-id

http://salesforce.stackexchange.com/questions/15968/updating-a-record-based-on-external-id-which-are-not-unique

All Answers

Vinita_SFDCVinita_SFDC
Hello,

Please refer following thread for possible workaround:

http://salesforce.stackexchange.com/questions/27812/mass-delete-custom-object-records-using-external-id

http://salesforce.stackexchange.com/questions/15968/updating-a-record-based-on-external-id-which-are-not-unique
This was selected as the best answer
Murthy vvrMurthy vvr
Hi Vinita,

Thanks for the response.

Followed similar approach as specified in first link and solved the problem.