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
DJP1SDJP1S 

Save error: Comparison arguments must be compatible types: Schema.SObjectField, String

I'm getting the topic title's error on my trigger logic - I'm just trying to filter out fields where the Month field is "Totals" before passing trigger.new to my class.

 

trigger ClientAnalyticsAfterInsertUpdateMonth on Client_Analytics__c (after insert, after update) {
    
    private ClientAnalyticsAfterUpdate caau;
    
    if(Client_Analytics__c.Month__c == 'Totals'){        
	    if (trigger.isAfter) {
	        if (trigger.isUpdate || trigger.isInsert) {
	            caau = new ClientAnalyticsAfterUpdate(trigger.new);
	        }
	    }
    }    
}

 

Best Answer chosen by Admin (Salesforce Developers) 
marcobmarcob

Hi,

since all triggers are bulk triggers by default, you must process them in a loop.

 

Example:

 

for (Client_Analytics__c ca : Trigger.new) {

  if(ca.Month__c == 'Totals') {

  ...
  }

}

 

 

Good luck!

Marco

All Answers

marcobmarcob

Hi,

since all triggers are bulk triggers by default, you must process them in a loop.

 

Example:

 

for (Client_Analytics__c ca : Trigger.new) {

  if(ca.Month__c == 'Totals') {

  ...
  }

}

 

 

Good luck!

Marco

This was selected as the best answer
DJP1SDJP1S

Oh duh - thanks!