You need to sign in to do that
Don't have an account?
Qihao Guo
debug code
trigger addCase on Account (After update) {
List<Account> allAccounts = new List<Account>([Select id,(select id from cases where status in('New','Open')) from account where id in :Trigger.new]);
List<Case> newCases = new List<Case>();
for(Account myAccount :allAccounts){
if(myAccount.cases !=null){
Case c = new Case();
c.Accountid = myAccount.Id;
c.Type = 'ICM';
c.Origin = 'WEB';
c.Status = 'New';
newCases.add(c);
System.debug('create successfully');
}
}
if(!newCases.isEmpty()){
insert newCases;
System.debug('create successfully');
}
}
Here is my code to create a new case. If I want to debug, what code should I put in execute anonymous windows?
List<Account> allAccounts = new List<Account>([Select id,(select id from cases where status in('New','Open')) from account where id in :Trigger.new]);
List<Case> newCases = new List<Case>();
for(Account myAccount :allAccounts){
if(myAccount.cases !=null){
Case c = new Case();
c.Accountid = myAccount.Id;
c.Type = 'ICM';
c.Origin = 'WEB';
c.Status = 'New';
newCases.add(c);
System.debug('create successfully');
}
}
if(!newCases.isEmpty()){
insert newCases;
System.debug('create successfully');
}
}
Here is my code to create a new case. If I want to debug, what code should I put in execute anonymous windows?
Try this :-
Execute above code in Anonymous window and then check the debug log.
Kindly mark it as the best answer if it works for you.
Thanks & Regards,
Priya Ranjan