+ Start a Discussion
SFDC 2017SFDC 2017 

Read data through excel and delete records through apex

Is there any way to read data from excel or fetch data from excel and those records need to delete using apex .I know we can use data loader but for big objects dataloader is not possible so i am in need of doing it by fetching data from excel and delete using apex.

Any suggestion please
Khan AnasKhan Anas (Salesforce Developers) 
Hi,

Greetings to you!

Please refer to the below links which might help you further with the above requirement. It is related to insertion but you can use the logic to delete the records.

https://salesforce.stackexchange.com/questions/158952/create-contact-records-reading-from-csv-without-hard-coding

http://www.forcetree.com/2010/08/read-and-insert-records-from-csv-file.html

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
SFDC 2017SFDC 2017
Thanks Khan for your prompt reply,.but the above one already i tried but for deletion its not happening.
Britto Fernandez 2Britto Fernandez 2
Dear SFDC 2017,

It is possible to read from CSV(upload it either static resource or content document/version) in apex and then read through the records and then delete each or in batch.

Regards,
SFDC 2017SFDC 2017
Thanks Britto.It would be helpful if you share some sample code for reference.