You need to sign in to do that
Don't have an account?
ethan hunt
Trigger For Case
Hi,
I am writing a trigger where if Case is Closed then the account related to that case will get deleted.
trigger Case2Account on Case (after update)
{
list<account> acclist = new list<account>();
for(case ca:trigger.old)
{
if (ca.status='Closed')
{
Account acc = new Account();
acc.Id = ca.AccountId;
delete acc;
}
}
}
Please help
trigger Case2Account on Case (after update)
{
list<account> acclist = new list<account>();
try{
for(case ca:trigger.old)
{
if (ca.status='Closed')
{
Account acc = new Account();
acc.Id = ca.AccountId;
acclist.add(acc);
}
}
delete acclist ;
}
catch(exception e){
}
}
I think this might be work...
trigger Case2Account on Case (after update)
{
list<account> acclist = new list<account>();
List<Id> accid=new List<Id>();
try{
for(case ca:trigger.New)
{
if (ca.status='Closed')
{
accid.add( ca.AccountId);
}
}
List<Account> acc=[Select id,Name from Account where id in:accid];
for(Account a:acc){
acclist.add(a);
}
delete acclist;
}
catch(exception e){
}
}