I'm trying to write an Apex trigger that makes a field on the Contact called Meeting Date equal to the Meeting Date field on the Opportunity. For some reason I'm getting an error saying "Expression cannot be assigned at line -1 column -1". Which apparently means that the SOQL query isn't pulling any information?
Very new to Apex/Coding so any guidance helps.
Thanks!
trigger updateMeetingDate on Contact (before update) {
List<Opportunity> newOppList = [Select Opportunity.Meeting_Date__c
From Opportunity
Where Opportunity.Type = 'New Business'
And(Opportunity.StageName = 'TQL' OR Opportunity.StageName = 'SAL')
];
if(Contact.Open_Opportunity_Count__c = 1){
Contact.Meeting_Date__c = Opportunity.Meeting_Date__c;
}
}
Best Answer
You have an assignment expression, using the assignment operator (single equals =) where a Boolean expression is expected.
You should use the equality operator (double equals ==) instead to test equality.
See Understanding Expression Operators for the official documentation.