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
betterbhushanbetterbhushan 

Error: Compile Error: unexpected token: 'trigger' at line 1 column 0 while creating trigger

I am trying to create trigger but getting..

 

Error: Compile Error: unexpected token: 'trigger' at line 1 column 0

 

the code:

 

trigger keywordAccountUpdate on KeywordAccountAssociation__c (after insert, after update){
    set<id> = new set<id>();
    for (KeywordAccountAssociation__c a : Trigger.new)
        accountIds.put(a.Account__c);
    map<id,Account> accountMap = new map<id,Account>([select id, DD_Segment__c from Account where id in :accountIds]);
    for (KeywordAccountAssociation__c kaa : Trigger.new){
        if (AccountMap.containskey(kaa.Account__c)){
            Account thisAccount = AccountMap.get(kaa.Account__c);
            String s = thisAccount.DD_Segment__c + ';new value'; // Always add value
            if ((thisAccount.DD_Segment__c).contains('second value')
                s += ';second value';
            AccountsToUpdate.add(new Account(id=thisAccount.id, DD_Segment__c = s));
        }
    }
}

 

bob_buzzardbob_buzzard

Did you create this via the trigger dropdown in the IDE or the triggers page on the UI?  I'm wondering if you might have created an apex class and then tried to populate it with a trigger?