You need to sign in to do that
Don't have an account?
devloper sfdc
trigger Stuck_on_Auto_Escalate_Status on Case (before insert, before update ) {
for(Trigger_Control__c tc:Trigger_Control__c.getall().values()){ //this is a custom setting (checkbox field)
if(tc.Action_Auto_Escalation__c==true)
{
for(case cs:trigger.new)
{
if(cs.Status=='Action - Automated Escalation')
{
cs.Stuck_on_Action_Automated_Escalation__c=true;
}
}
}
}
}
please help to write test class of this trigger
trigger Stuck_on_Auto_Escalate_Status on Case (before insert, before update ) {
for(Trigger_Control__c tc:Trigger_Control__c.getall().values()){ //this is a custom setting (checkbox field)
if(tc.Action_Auto_Escalation__c==true)
{
for(case cs:trigger.new)
{
if(cs.Status=='Action - Automated Escalation')
{
cs.Stuck_on_Action_Automated_Escalation__c=true;
}
}
}
}
}
As manish suggested you need to insert custom Setting Record manually. It is not best practice to SeeAllData = true in test classes. Please use below code: Please let me know if you have any question.
Mark as best answer if helped.
Regards,
Ramakant
All Answers
You can do it either using (seeAllData=false) or (seeAllData=true).
Use below code if you are using seeAllData=true (not recommended as per best practices)
Create custom setting records manually in test method if you are using seeAllData=false
Let me know if you have further questions on this.
Thanks,
Manish
As manish suggested you need to insert custom Setting Record manually. It is not best practice to SeeAllData = true in test classes. Please use below code: Please let me know if you have any question.
Mark as best answer if helped.
Regards,
Ramakant