You need to sign in to do that
Don't have an account?
justinpauldavis
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.
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'; } }