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
tsreenu92tsreenu92 

Apex trigger error

trigger FieldUpdate on Customer__c (before insert,before update) {
    if(Customer__c.MRRMonthly__c!=CustomerInfo__c.MRR__c)
    {
        Customer__c.MRRMonthly__c=Customer__c.MRR__c;
    }

}

 

I am getting an error like this:

 

Error: Compile Error: Expression cannot be assigned at line -1 column -1. can any help me to solve this.

Navatar_DbSupNavatar_DbSup

Hi,
Try the below code to work around to sort out your issue.


trigger FieldUpdate on Customer__c (before insert,before update)
{
for(Customer__c c:Trigger.new)
{
if(c.MRRMonthly__c!=c.MRR__c)
{
c.MRRMonthly__c=c.MRR__c;
}
}

}

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.