You need to sign in to do that
Don't have an account?
uday kiran 216
System.QueryException: List has no rows for assignment to SObjects
Test.starttest();
List<Database.DeleteResult> result2 = Database.delete(oppList, false);
LogDAO.logDatabaseError(result2, 'LagDAO:deleteResult');
Test.stopTest();
system.assertequals(true, opp.Id !=null);
String errMsg = 'Your attempt to delete Test Opp could not be completed beacuse it is associated with the follow opportunity information.';
System.assert(([SELECT Details__c from Log__c Where ExcceptionType__c = 'Delete_Failed' LIMIT 1]. Details__c).contains(errMsg));
List<Database.DeleteResult> result2 = Database.delete(oppList, false);
LogDAO.logDatabaseError(result2, 'LagDAO:deleteResult');
Test.stopTest();
system.assertequals(true, opp.Id !=null);
String errMsg = 'Your attempt to delete Test Opp could not be completed beacuse it is associated with the follow opportunity information.';
System.assert(([SELECT Details__c from Log__c Where ExcceptionType__c = 'Delete_Failed' LIMIT 1]. Details__c).contains(errMsg));
As the error suggests, can you check if the SOQL query returns any records?
The article https://help.salesforce.com/articleView?id=000328824&type=1&mode=1 should help.
If this information helps, please mark the answer as best. Thank you
Please use below code:-
if you need any assistanse, Please let me know!!
Kindly mark my solution as the best answer if it helps you.
Thanks
Mukesh
Here is modified code, as per my understanding
Test.starttest();
List<Database.DeleteResult> result2 = Database.delete(oppList, false);
LogDAO.logDatabaseError(result2, 'LagDAO:deleteResult');
Test.stopTest();
/* just one doubt, from where you are fetching this record "opp"?*/
system.assertequals(true, opp.Id !=null);
String errMsg = '%Your attempt to delete Test Opp could not be completed beacuse it is associated with the follow opportunity information.%';
Log__c logRecord = [SELECT Details__c from Log__c Where ExcceptionType__c = 'Delete_Failed' and Details__c LIKE: errMsg LIMIT 1];
System.assert(logRecord != null);