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
Angel HFAngel HF 

Error Apex Basics & Database / Writing SOQL Queries

Hi,

I am trying to complete the trailhead module Apex Basics & Database / Writing SOQL Queries. When I am checking the challenge I got the bllow eerror:

Challenge Not yet complete... here's what's wrong:
There was an unexpected error in your org which is preventing this assessment check from completing: System.DmlException: Delete failed. First exception on row 0 with id 0032400000nIEIpAAO; first error: DELETE_FAILED, Your attempt to delete Joe Doe could not be completed because it is associated with the following cases.: 00001136 : []

I have not clue how to solve it, since there is not any contact named Joe Doe and any case 00001136. My code seems to be fine:
 
public class ContactSearch {

    public static List<Contact> searchForContacts (String lastName, String postalCode){
    	List<Contact> con = new List<Contact>(); 
        con = [SELECT Id FROM Contact WHERE (LastName =: lastName AND MailingPostalCode =: postalCode )];
        
        return con;
    }
}

Thanks in advance.




 
Best Answer chosen by Angel HF
Amit Chaudhary 8Amit Chaudhary 8
It look like in your you have any Trigger on Account or Contact Object which is creating Case. Please deactivate that Trigger and try again same code.

All Answers

UC InnovationUC Innovation
Hi Angel,

The code you posted seems fine. Where are you deleting the record? I would try searching by that ID: 0032400000nIEIpAAO, and see what comes up. 
SwarnaSankhaSinghSwarnaSankhaSingh

Hi Angel HF,

Your code is fine and has no issues.

Now you did mention that you dont have Contact or the case record in your org; did you just search for them or did you try pulling up the Contact record using the SFDC ID "0032400000nIEIpAAO" mentioned in the error message?

Can you try to logout from the Developer account you are logged into while checking the challenge, logout of your trailhead account and then try to log back into your Trailhead & developer accounts to see if the problem persists?

Kind Regards,
Swarna.

Vyankatesh Choulwar 15Vyankatesh Choulwar 15
Hi angel HF,

Is this a complete code? you are not using Delete DML statement anywhere in this code. Can you check if there are any other tabs opened in your developer console , that might be throwing this exception.

Thanks,
Vyankatesh
Amit Chaudhary 8Amit Chaudhary 8
It look like in your you have any Trigger on Account or Contact Object which is creating Case. Please deactivate that Trigger and try again same code.
This was selected as the best answer