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
Prakash Reddy 17Prakash Reddy 17 

Email notification for particular user in page layout via Trigger

Please help, I am new to developing / Apex code and am trying to set up a trigger email notification to one of the user  from a picklist field (on an Activity)based on a different picklist entry (User)

 

I am getting the following error:

Error: Compile Error: Invalid bind expression type of Lead for column of type String 

And honestly I have no clue what I need to do to fix this...!

 

Here is my first attempt:

 

trigger EmailTrigger on Lead (before insert) {
    
      EmailClass.AlertEmail();
    
}

Apex Class:

public with sharing class EmailClass{
   public static void AlertEmail(){     
        List<Lead> leadlist = new List<Lead>();
        leadlist = [SELECT Id,Name, Assign_to_Lead_Source__c FROM Lead];
      List<User> userlist = new List<User>();
       userlist = [SELECT Name,Email FROM user WHERE Name IN  :leadlist];  
       }
}
After getting User name from picklist ,want  to write email notification.
EldonEldon
So you want to email the user you selected in that picklist when you insert a lead? or is there any other criteria based on a field?
Prakash Reddy 17Prakash Reddy 17
Yes, I want to email the user selected from picklist values when inserting a lead. Please Help me Eldon for the above code,

Regards,
Prakash