• sibil joe
  • NEWBIE
  • 0 Points
  • Member since 2022

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 2
    Replies
public static void setAccount(List<Account> newList){
    List<Account> pirList = new List<Account>();    
    List<Account> p1 = new List<Account>();
    for(Account newAcc: newList){
            
            if(newAcc.RecordTypeId == pirRecId){
                p1.add(newAcc);
                
                p1 = [SELECT id,FirstName,LastName,MiddleName 
                                FROM Account 
                                WHERE
                                FirstName =: newAcc.FirstName AND
                                LastName =: newAcc.LastName AND
                                MiddleName =: newAcc.MiddleName ];

                for(Account patient:p1){
                    patient.lookup = newAcc.Id;
                }
                update p1;
            }
        }    
   }
This function is called from a trigger in after insert
public static void setAccount(List<Account> newList){
    List<Account> pirList = new List<Account>();    
    List<Account> p1 = new List<Account>();
    for(Account newAcc: newList){
            
            if(newAcc.RecordTypeId == pirRecId){
                p1.add(newAcc);
                
                p1 = [SELECT id,FirstName,LastName,MiddleName 
                                FROM Account 
                                WHERE
                                FirstName =: newAcc.FirstName AND
                                LastName =: newAcc.LastName AND
                                MiddleName =: newAcc.MiddleName ];

                for(Account patient:p1){
                    patient.lookup = newAcc.Id;
                }
                update p1;
            }
        }    
   }
This function is called from a trigger in after insert
If I am using below Query
SELECT CaseNumber from Case where  ClosedDate > LAST_N_DAYS:31

To get all case numbers  which have been closed within last 30 days , It is not giving any result , even though Some cases exist in Database closed within the 30 days.

I could not understand , why I am not getting correct result.
Thanks
Yogendra Rishishwar