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.


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; 

You have an assignment expression, using the assignment operator (single equals =) where a Boolean expression is expected.

if(Contact.Open_Opportunity_Count__c = 1)

You should use the equality operator (double equals ==) instead to test equality.

if(Contact.Open_Opportunity_Count__c == 1)

See Understanding Expression Operators for the official documentation.

Your Answer

