You need to sign in to do that
Don't have an account?
Suhaas Kapardhi B S
Trigger on case to update the account name
I need o update the accounts name in the case record when I create a Case using custom modal which i have created. Below is the code which I have written.
trigger modalAccount on Case (after insert, after update) {
Set<id> cas = new Set<id>();
List<Account> acclist = new List<Account>();
for(Case c:Trigger.new ){
cas.add(c.AccountId);
}
List<Account> acc = [Select id, Name From Account Where id in: cas];
for(Account temp:acc){
temp.Name= 'sample Account Name';
acclist.add(temp);
}
update acclist;
}
The code which I have written is not working.
Please help
trigger modalAccount on Case (after insert, after update) {
Set<id> cas = new Set<id>();
List<Account> acclist = new List<Account>();
for(Case c:Trigger.new ){
cas.add(c.AccountId);
}
List<Account> acc = [Select id, Name From Account Where id in: cas];
for(Account temp:acc){
temp.Name= 'sample Account Name';
acclist.add(temp);
}
update acclist;
}
The code which I have written is not working.
Please help
Which means there is an issue in LWC component. You need to check your LWC component. It is creating case but not relating the Case to the Account.
The trigger which you have written is working as intended.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
I see this code is working as expected. The Account is updating . The Account and Case here we are using are standard ones.
Can you share the modal which you created and are Account and Case standard?
Thanks,
This should be issue. If the Case is creating correctly and assoiating to the Account this logic will work.
Thanks,
Which means there is an issue in LWC component. You need to check your LWC component. It is creating case but not relating the Case to the Account.
The trigger which you have written is working as intended.
If this solution helps, Please mark it as best answer.
Thanks,