You need to sign in to do that
Don't have an account?
Caroline Poole 9
Apex Trigger - No Test Class
Hi. I found this apex class sample online. It triggered successfully in my sandbox. The trigger finds a string in a custom field and replaces it with a new character. When deploying to my production org, I realized I don't have a test class.
This is the Apex Trigger:
trigger replaceCharactersSB on rC_Connect__Batch_Upload__c (before insert) {
String str = '>';
String str2 = '>';
String replacement = '>';
for(rC_Connect__Batch_Upload__c des : trigger.new){
if(des.SB_donation_allocations__c.contains(str)){
des.SB_donation_allocations__c = des.SB_donation_allocations__c.replace(str, replacement);
}
if(des.SB_donation_allocations__c.contains(str2)){
des.SB_donation_allocations__c = des.SB_donation_allocations__c.replace(str2, replacement);
}
}
}
Anyone know how to create a test class for this? Thank you for your help!
This is the Apex Trigger:
trigger replaceCharactersSB on rC_Connect__Batch_Upload__c (before insert) {
String str = '>';
String str2 = '>';
String replacement = '>';
for(rC_Connect__Batch_Upload__c des : trigger.new){
if(des.SB_donation_allocations__c.contains(str)){
des.SB_donation_allocations__c = des.SB_donation_allocations__c.replace(str, replacement);
}
if(des.SB_donation_allocations__c.contains(str2)){
des.SB_donation_allocations__c = des.SB_donation_allocations__c.replace(str2, replacement);
}
}
}
Anyone know how to create a test class for this? Thank you for your help!
Hm, try this then:
Does it say which row the "variable does not exist: CBU" error happens on?All Answers
variable does not exist: CBU
and
Invalid type: rC_Connect_Batch_Upload__c
Hm, try this then:
Does it say which row the "variable does not exist: CBU" error happens on?