• Ajeet Singh 259
  • NEWBIE
  • 25 Points
  • Member since 2021

  • Chatter
    Feed
  • 1
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 1
    Replies
Please help me solve the reason for the two errors:

Line 8: Expression cannot be assigned
Line 17: Illegal assignment from List to Id
 
trigger SelectVacationPackage on Vacation_Package__c (after insert, after update) {
	List<Vacation_Package__c> PackagesToUpdate = new List<Vacation_Package__c>();
    
    List<Vacation_Package__c> WorkingPackages = [SELECT Id, Package_Type__c, Sales_Company__c, Package_Status__c 
												  FROM Vacation_Package__c WHERE Id In :Trigger.New];
    
    for(Vacation_Package__c vp: WorkingPackages){        
            if(vp.Package_Type__c = 'Select' && vp.Package_Status__c = 'Active'){
      			 PackagesToUpdate.add(vp);
       		 }
	}

    for (Vacation_Package__c vsp : PackagesToUpdate){
        
        //Sales_Company__c is a Lookup field requiring an ID
        
        vsp.Sales_Company__c = [Select ID from Account WHERE Name = 'Upgrade Sales'];
    }

    
    if(PackagesToUpdate.size() > 0){
        update PackagesToUpdate;       
    }   
}

Thank you
Please help me solve the reason for the two errors:

Line 8: Expression cannot be assigned
Line 17: Illegal assignment from List to Id
 
trigger SelectVacationPackage on Vacation_Package__c (after insert, after update) {
	List<Vacation_Package__c> PackagesToUpdate = new List<Vacation_Package__c>();
    
    List<Vacation_Package__c> WorkingPackages = [SELECT Id, Package_Type__c, Sales_Company__c, Package_Status__c 
												  FROM Vacation_Package__c WHERE Id In :Trigger.New];
    
    for(Vacation_Package__c vp: WorkingPackages){        
            if(vp.Package_Type__c = 'Select' && vp.Package_Status__c = 'Active'){
      			 PackagesToUpdate.add(vp);
       		 }
	}

    for (Vacation_Package__c vsp : PackagesToUpdate){
        
        //Sales_Company__c is a Lookup field requiring an ID
        
        vsp.Sales_Company__c = [Select ID from Account WHERE Name = 'Upgrade Sales'];
    }

    
    if(PackagesToUpdate.size() > 0){
        update PackagesToUpdate;       
    }   
}

Thank you