Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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; 
   }            
}
share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.