How to resolve the Database.Delete salesforce Error?

639    Asked by BuffyHeaton in Salesforce , Asked on Jun 1, 2023
List c = [SELECT ID FROM Contact WHERE AccountId !='00190000016ozwL']; System.debug(c.size()); Database.SaveResult[] srList = Database.delete(c, false);
This is the anonymous apex that I am trying to execute.

I am getting the following error while executing.

Illegal assignment from LIST to LIST

Not sure why am I getting this error because "c" is a collection only. Can you let me know ?

Answered by Aswini Lobo

Database.delete salesforce returns Database.deleteResult. Database.saveResult is returned for insert and update operations.

So you should change you code to:
Database.deleteResult[] srList = Database.delete(c, false);You can find more info here: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_methods_system_database_deleteresult.htm

Your Answer

Interviews

Parent Categories