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
justinpauldavisjustinpauldavis 

Apex trigger for lookup field (before insert, before update)

I'm a beginner at apex, and I've written this for a custom object called "Account". It works just fine for standard leads and accounts - just not the custom account object. I'm getting the error at the beginning of the third Account__c:

 

Invalid identifier: Account__c

 

trigger SetAccountField on Account__c (before insert, before update) {
    for (Account__c Account__c : Trigger.new) {
        Account__c.Scoring__c = '0017000000TEs0O';
    }
 }

 

 

Any help would be much appreciated. 

Best Answer chosen by Admin (Salesforce Developers) 
GlennAtAppirioGlennAtAppirio

Apex doesn't like it when you use __c as a suffix on a variable name.  Try this instead:

 

 

trigger SetAccountField on Account__c (before insert, before update) { for (Account__c a : Trigger.new) { a.Scoring__c = '0017000000TEs0O'; } }