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
raysfdc1988raysfdc1988 

getting compiler error while running a trigger

Hi getting above error:Compile Error: Expression cannot be assigned at line -1 column -1

I am understanding what is this error and how debug it??
Is there any need od change in code,,Please help me

trigger AttachmentandReferralpoints on Student_Profile__c (before insert, after insert,after update) {
if(trigger.isupdate)
{
  list<string> preferredcoursenames=new list<string>();
      list<string> preferredtimeslot=new list<string>();

     for(student_profile__c studentprofile:trigger.new)
     {
       preferredcoursenames.add(studentprofile.Prefered_Course__c);
        preferredtimeslot.add(studentprofile.Preferred_Course_Start_Date__c);
      }
      list<string> timeslots=new list<string>();
       for(string splitvals:preferredtimeslot)
      {
       list<string> s=splitvals.split(',');
       timeslots.add(s[0]);
     
       }
       map<string,id> courseNameIdMap=new map<string,id>();
   for(Course_Program__c programs:[select id ,name, Type_of_Program__c,Month__c from
                                     Course_Program__c where Type_of_Program__c in :preferredcoursenames and month__c=:timeslots])
    {
       courseNameIdMap.put(programs.Type_of_Program__c ,programs.id);
  
    }
    list<Course_Program__c> CourseProgram = new list<Course_Program__c>();
  
     for(student_profile__c updatingstudentprofile:trigger.new)
     {
       ///preferredcoursenames.add(studentprofile.Prefered_Course__c);
       if(courseNameIdMap.containskey(updatingstudentprofile.Prefered_Course__c))
       {
       updatingstudentprofile.Course_Program__c=courseNameIdMap.get(updatingstudentprofile.Prefered_Course__c);
       }
       else
        {
         Course_Program__c newprogram =new Course_Program__c();
         Course_Program__c.name=updatingstudentprofile.Course_Name__c;
         Course_Program__c.Type_of_Program__c=updatingstudentprofile.Prefered_Course__c;
         Course_Program__c.month__c=updatingstudentprofile.Preferred_Course_Start_Date__c;
       
         CourseProgram.add(newprogram);
        }
        }
     if(!CourseProgram.isempty())
     insert CourseProgram ;   
}
}
Sonam_SFDCSonam_SFDC
Could you please try to change the following:
list<string> preferredcoursenames=new list<string>();
list<string> preferredtimeslot=new list<string>();

to

list<string> preferredcoursenames;
list<string> preferredtimeslot;
 and try to compile the trigger..