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
Gar SpencerGar Spencer 

Trigger has bugs...... Is there a shorter way to do what I am trying to accomplish in APEX?

I have made changes and it is still not compiling or saving to SFDC.....  here is my modified code after debugging.  Can anyone see what I am missing.

First thing that should happen is when a new buyer record is saved or updated (identified by the Active_Buyers__c) field is search through system for records that have (Active_Seller__c) field checked.

Then it should query the account records and pull the ID, name, List Price, Price Range, Owner Email, and Last Modified Email. from the account object where the List Price <= to the Price range  and store the results temporarily.

After matches are returned there should be an email notification sent to the of the record that has the Active Seller field checked. with the 

Subject being New Buyer Found, 
Body should contain the account name (hyperlink) owner name and owner email of the account with the Active buyers field checked

trigger BuyerSellerMatchTrigger on Account (after insert,after update){
// Capture all records that have Active_Buyers__c field equals true
      List <Account> BuyerList = new List<Account>();
      Set<String> nameSet= new Set<String>();
      Set<String> emailSet;
      Boolean Active_Buyers = true;
           if(Active_Buyers__c) {
//check to determine size and the query fields of accounts for the buyer list
        if(buyerList.size()>0 && nameSet.size()>0){
       List<Account>listOfAccounts=[ select id, name,, Maximun_Price_Range__c, Price_range__c 
           from Account where (name in: nameSet) and Active_Seller__c = True and Listed_Price__c <= Price_Range__c];
//Map the result set of active buyers to active sellers
         Map<Id, Set<String>>mapOfAccounts=new Map<Id, Set<String>>();
         for(Account a:listOfAccounts){
            for(account trgrAccountbuyerList){
               if(trgrAccount.Active_Seller__c = True){
                       else {
                            emailSet=new Set<String>();
// Email notification trigger
            for(Id idey:mapOfaccounts.keySet()){                              
                String emailMessage='Buyer Email account-'+ idey;
                Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
                String[] toAddresses=new List<String>();
                mail.setSenderDisplayName('Buyer Email'); 
                Messaging.sendEmail(new Messaging.SingleEmailMessage[]{mail});                               
May I know  what is the issue that you are getting while saving the code?
Gar SpencerGar Spencer
i get an error saying that need to enable email for user profile, but it is enabled.