You need to sign in to do that
Don't have an account?
Suhaas Kapardhi B S
Trigger on case to update its related account name
Hi, I have created a trigger on case to update its related account name when I create a new case, but I am not sure about my code.Please help.
trigger modalAccount on Case (after insert) {
Set<id> cas = new Set<id>();
List <Case> ca = [SELECT AccountId,id From Case Where id in:trigger.new];
for(Case c:ca ){
cas.add(c.AccountId);
}
List<Account> acc = [Select Name From Account Where id in: cas];
for(Account temp:acc){
ca.AccountId=temp.Name;
}
}
Thanks & Regards
Suhaas
trigger modalAccount on Case (after insert) {
Set<id> cas = new Set<id>();
List <Case> ca = [SELECT AccountId,id From Case Where id in:trigger.new];
for(Case c:ca ){
cas.add(c.AccountId);
}
List<Account> acc = [Select Name From Account Where id in: cas];
for(Account temp:acc){
ca.AccountId=temp.Name;
}
}
Thanks & Regards
Suhaas
Can I know what you want the account name to be updated to? I have written the code below to update the Account name to some text fied.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
Thanks,
Do you meant to add the Case number to Account Name. Can you clarify more with an example so I can provide the solution.
Thanks,