Skip to main content

when i am copying the code given in the trailhead challenge to developer console, for this code i am getting the below error:

public class RestrictContactByName {

    trigger RestrictContactByName on Contact (before insert, before update) {

  //check contacts prior to insert or update for invalid data

  for(Contact c : Trigger.New) {

    if(c.LastName == 'INVALIDNAME') {

      //invalidname is invalid

      c.AddError('The Last Name "'+c.LastName+'" is not allowed for DML');

    }

  }

}

I am getting this error:Expecting '}' but was: 'trigger'

 

#Trailhead Challenges

2 respuestas
0/9000