function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Getting complie error while executing an trigger



I am trying to follow the following trigger


trigger leadDupCheck on Lead(before insert, before update) {
if ( != null) {
    Integer dupCount =[select count() from Lead WHERE email =];
     if ( dupCount > 0 ) {'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 ( != null){
        integer ecount = [select count() from Candidate__c WHERE Email__c =];
        if (ecount > 0){
  'Candidate already exists');


Please let me know what this error is about and how to proceed further




My offhand guess would be that is not a single SObject, but a List of objects.  Look into writing bulk safe triggers.  Best, Steve.

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.