You need to sign in to do that
Don't have an account?
Amit Jain 5
Manipulating Records with DML
The Trailhead challenge is to create a metohd for inseting accounts.
I have the follwing code:
public class AccountHandler {
public static Account insertNewAccount (String accName){
if(accName!=''){
try{
Account a = new Account(Name=accName);
insert a;
System.debug('Account created');
return a;
} catch(Exception e){
System.Debug('Account not created');
return null;
}
} else {
return null;
}
}
}
This runs fine in Anonyomous window, but when I check the challenge from Trail head it thorws this error:
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 0019000001duAuoAAE; first error: DELETE_FAILED, Your attempt to delete My Test Account could not be completed because it is associated with the following cases.: 00001066 : []
I have the follwing code:
public class AccountHandler {
public static Account insertNewAccount (String accName){
if(accName!=''){
try{
Account a = new Account(Name=accName);
insert a;
System.debug('Account created');
return a;
} catch(Exception e){
System.Debug('Account not created');
return null;
}
} else {
return null;
}
}
}
This runs fine in Anonyomous window, but when I check the challenge from Trail head it thorws this error:
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 0019000001duAuoAAE; first error: DELETE_FAILED, Your attempt to delete My Test Account could not be completed because it is associated with the following cases.: 00001066 : []
The issue was there was a trigger on Account object, I made the trigger inactive and then was able to pass the trailhead module.
Thanks Vivek for taking time to respond.
All Answers
My wild guess is may be your org has a dupchecker that deletes the old records with any new record come with the similar name or some other prgrm is deleting records ?? otherwise their is no way for delete to execute.
Once check the account with '0019000001duAuoAAE' is having the same name of the record you are trying to insert ?
The issue was there was a trigger on Account object, I made the trigger inactive and then was able to pass the trailhead module.
Thanks Vivek for taking time to respond.