You need to sign in to do that
Don't have an account?
Kalpana Dhanajayaraj
Method not working
Public static void validateCase(List<case> cases){
for(Case c: cases){
if((c.recordTypeid == Label.RT_Deal_Support && c.Type == 'Insight Tag Implementation') && (String.isBlank(c.contact.Name) || c.Top_Level_Domain__c == null))
{
c.addError('Top-Level Domain and Contact Name are required when Record type = Deal Support and Type = Insight Tag Implementation');
}
}
}
calling the above method via trigger
trigger CaseTrigger on Case (before insert, before update, after insert, after update, after delete, after undelete) {
if(GeneralUtil.triggerOverrideCheck('CaseTrigger')){
if(Trigger.isBefore){
CaseUtil.validateCase(Trigger.new);
I created a case of record type 'Deal Support' and Type = Insight Tag Implementation.
And did not enter value for Contact name and Top-level domain.
But the error was not thrown.
for(Case c: cases){
if((c.recordTypeid == Label.RT_Deal_Support && c.Type == 'Insight Tag Implementation') && (String.isBlank(c.contact.Name) || c.Top_Level_Domain__c == null))
{
c.addError('Top-Level Domain and Contact Name are required when Record type = Deal Support and Type = Insight Tag Implementation');
}
}
}
calling the above method via trigger
trigger CaseTrigger on Case (before insert, before update, after insert, after update, after delete, after undelete) {
if(GeneralUtil.triggerOverrideCheck('CaseTrigger')){
if(Trigger.isBefore){
CaseUtil.validateCase(Trigger.new);
I created a case of record type 'Deal Support' and Type = Insight Tag Implementation.
And did not enter value for Contact name and Top-level domain.
But the error was not thrown.
Also, although I don't think this is the issue, the related contact record won't be populated on the trigger, so c.contact.Name won't contain a value. You should check the id in that situation.
I suggest you add some debug statements to your trigger to confirm the record ids/string values are correct.
one more point not related this issue, Trigger context is available in the apex method, no need to pass Trigger.new while invoking apex method from trigger.