You need to sign in to do that
Don't have an account?
Getting complie error while executing an trigger
Hi,
I am trying to follow the following trigger
trigger leadDupCheck on Lead(before insert, before update) {
if (Trigger.new.Email != null) {
Integer dupCount =[select count() from Lead WHERE email = :Trigger.new.Email];
if ( dupCount > 0 ) {
Trigger.new.email.addError('Lead is a duplicate');
} else {
}
}
}
I am able to excecute this trigger when used on the Object Lead, while trying to follow the same syntax on a custom object am getting an error
Error: Compile Error: Initial term of field expression must be a concrete SObject: LIST:SOBJECT:
i have replaced the object and field name appropriately
trigger t on Candidate__c (before insert, before update) {
if (trigger.new.Email__c != null){
integer ecount = [select count() from Candidate__c WHERE Email__c = :Trigger.new.Email__c];
if (ecount > 0){
Trigger.new.Email__c.addError('Candidate already exists');
}
}
}
Please let me know what this error is about and how to proceed further
thanks
KD
Thanks Steve. Following your suggestion when created a trigger for bulk I was able to execute it for the desired result. Thanks again for the response and pointer.
KD