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 class

public class UpdateField {
    public static void upd(List<Customer__c> c)
    {
        for(Customer__c p:c)
        {
            if(p.MRRMonthly__c!=CustomerInfo__c.MRR__c)
            {
                p.MRRMonthly__c=CustomerInfo__c.MRR__c;
            }
        }
    }
}

 

 

I am getting an error:   Error: Compile Error: Illegal assignment from Schema.SObjectField to Decimal at line 8 column 17

apex_keenapex_keen

I guess data type of MRRMonthly__c and MRR__c are not same.  Visit each custom object and verify it from 'Data Type' column

Abhinav GuptaAbhinav Gupta

This "CustomerInfo__c.MRR__c;" seems to be the problem, you need to change it to something else, as this is "Schema.SObjectField"

Aravind SriramAravind Sriram

Hi Sreenu,

 

What is this 'CustomerInfo__c'..? I guess it is a custom object.

How could you use a custom object directly with out instanciating it.

public class UpdateField {
    public static void upd(List<Customer__c> c)
    {
  CustomerInfo__c objCostInfo = new CustomerInfo__c();
        for(Customer__c p:c)
        {
            if(p.MRRMonthly__c!=objCostInfo.MRR__c)
            {
                p.MRRMonthly__c=objCostInfo.MRR__c;
            }
        }
    }
}