You need to sign in to do that
Don't have an account?

test trigger
Could you please advise me how to write test class for below
trigger Dcalup on Account (after update) {
for (Account myacc : Trigger.old) {
if (myacc.StrPhr_Do_Not_Call_Group_Practice__c == True) {
List<Account> Dccall = [SELECT StrPhr_Do_Not_Call_Group_Practice__c from Account where Phone= :myacc.Phone];
if (Dccall.size() > 0)
for (Account a : Dccall ) {
a.StrPhr_Do_Not_Call_Group_Practice__c = True;
update a;
}
}
}
}
trigger Dcalup on Account (after update) {
for (Account myacc : Trigger.old) {
if (myacc.StrPhr_Do_Not_Call_Group_Practice__c == True) {
List<Account> Dccall = [SELECT StrPhr_Do_Not_Call_Group_Practice__c from Account where Phone= :myacc.Phone];
if (Dccall.size() > 0)
for (Account a : Dccall ) {
a.StrPhr_Do_Not_Call_Group_Practice__c = True;
update a;
}
}
}
}
Please find the below modified code:
Here I considered:
(1) Corrected the logic.
(2) Bulkified the Trigger.
(3) Naming Convention.
(4) Alignment.
(5) Tested the code in my DE environment and it shows 100% with assertions.
Test Class:
Please do let me know if it helps you.
Regards,
Mahesh
All Answers
Please find the below modified code:
Here I considered:
(1) Corrected the logic.
(2) Bulkified the Trigger.
(3) Naming Convention.
(4) Alignment.
(5) Tested the code in my DE environment and it shows 100% with assertions.
Test Class:
Please do let me know if it helps you.
Regards,
Mahesh
regards
soma