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
Justin GareyJustin Garey 

Apex trigger to copy field value

I wrote a trigger to copy field date from one fiel to another. Keeping getting this error. Any suggestions?
Compile Error: expecting an equals sign, found ":" at Line 3 column 12 (highlighted)

 Trigger updateFields on Case (before update){

  for (Case : trigger.new){

    Serial_Number__c = SVMXC__Component__c;

  }

}
Mike OtterMike Otter
The for loop is expecting a variable name after the type (Case) but, instead, sees a colon and thus you get the error. Make it something like:

   for (Case c : trigger.new)
   {
        c.Serial_Number__c = SVMXC_Component__c;
    }

and it should pass.

Mike
P.S.  You may have an extra underscore after SVMXC but that may be your actual field name so don't worry about it.