function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Alex Waddell 12Alex Waddell 12 

Expression Cannot be assigned?!

Hello everyone,

I am in the process of writing a trigger that look to see if there are 3 communication notes in a record that meet a certain criteria.

When the third Communication_Note__c record is created i want it to update a field called Fuzion_billing_Date__c with the date of the third created Communication Note

Right now i am getting an error "Expression cannot be assigned" that occurs at my "If" statement on line 10. I have a feeling it is because my allAccounts list isn't associating the Communication_Note__c object and their records to the account

If anyone has any ideas i would love to hear them
 
trigger billingDate on Account (After insert) {
    For(Account myAcc : Trigger.New){
        List<Account> allAccounts = new List<Account>([Select id,Fuzion_Billing_Date__c
                                                      from account where id in :Trigger.new]);
        List<Communication_Note__c> ThreeUnsuccessful = [Select Id
                                                          From Communication_note__c
                                                          Where Fuzion_Type__c = 'Initial Phone Call'
                                                          AND Outcome__c = 'No Answer'
                                                          And Id = : myAcc.Id];  
        If(ThreeUnsuccessful.size() = 3){
            myAcc.Fuzion_Billing_Date__c = Date.today(); 
        }

    }
    }



 
Best Answer chosen by Alex Waddell 12
Alain CabonAlain Cabon
Hi,

If(ThreeUnsuccessful.size() == 3){
      myAcc.Fuzion_Billing_Date__c = Date.today();
 }

x = y Assignment operator (Right associative). Assigns the value of y to the L-value x. Note that the data type of x must match the data type of y, and cannot be null.

x == y Equality operator. If the value of x equals the value of y, the expression evaluates to true. Otherwise, the expression evaluates to false.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_expressions_operators_understanding.htm

Regards

All Answers

Alain CabonAlain Cabon
Hi,

If(ThreeUnsuccessful.size() == 3){
      myAcc.Fuzion_Billing_Date__c = Date.today();
 }

x = y Assignment operator (Right associative). Assigns the value of y to the L-value x. Note that the data type of x must match the data type of y, and cannot be null.

x == y Equality operator. If the value of x equals the value of y, the expression evaluates to true. Otherwise, the expression evaluates to false.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/langCon_apex_expressions_operators_understanding.htm

Regards
This was selected as the best answer
Alex Waddell 12Alex Waddell 12
Alain, Thank you so much :D

I appreciate the link to the documentation as well