You need to sign in to do that
Don't have an account?
Timothy Smith
Trigger Code error - Expression cannot be assigned and Illegl assignment
Please help me solve the reason for the two errors:
Line 8: Expression cannot be assigned
Line 17: Illegal assignment from List to Id
Thank you
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
Query return list object. Here require an id of record. used instead of :-
vsp.Sales_Company__c = [Select ID from Account WHERE Name = 'Upgrade Sales'].Id;