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
Priya Mukherjee 13Priya Mukherjee 13 

I am getting a error "line 24, col 30. Expression cannot be assigned" which ic ' Account ac=peronAccountList1.get(sc.AccountId);'

My code goes like this..


//******** Service Contract *******// 

public class ServiceContractTriggerHelper {
    
    public static void updateAddress(List<ServiceContract> src){
        
        Set<ID> acclist = new Set<ID>();
        
        Id rectype = Schema.SObjectType.ServiceContract.getRecordTypeInfosByName().get('Medical Alert Service').getRecordTypeId();
        
        for(ServiceContract sc: src){
            acclist.add(sc.AccountId);
        }
        
        Map<Id,Account> peronAccountList1 = new Map<Id, Account>();
        List<Account> aclst =  [Select Id,Is_Active_Shipping_Address__c,Is_Active_Alternate_Address__c,Alternate_City__c,Alternate_Country__c,
                                Township_Borough_Municipality_B__c,Township_Borough_Municipality_S__c FROM Account WHERE Id IN :acclist];
                                
        for(Integer i=0; i<aclst.size(); i++){
            peronAccountList1.put(aclst[i].id,aclst[i]);
        }
        for(ServiceContract sc: src){
            Account ac=peronAccountList1.get(sc.AccountId);
            if(accIdwithlist.get(sc.AccountId)!=null && sc.RecordType = rectype){
                if(ac.Is_Active_Shipping_Address__c){
                    sc.City__c = ac.Alternate_City__c;
                    sc.Country__c = ac.Alternate_Country__c;
                    sc.Township_Borough_Municipality__c = ac.Township_Borough_Municipality_S__c;
                }
                
                if(ac.Is_Active_Alternate_Address__c){
                    sc.City__c = ac.Alternate_City__c;
                    sc.Country__c = ac.Alternate_Country__c;
                    sc.Township_Borough_Municipality__c = ac.Township_Borough_Municipality_S__c;
                }
            }
            
        }
    }

}
ManojjenaManojjena
Hi Priya,

I think you are getting error from just below the line you have mentioned .You are getting error from below line 
 
if(accIdwithlist.get(sc.AccountId)!=null && sc.RecordType = rectype){

Above line you are comparing with sc.RecordType = rectype  where you need to change like sc.RecordType == rectype​

I think this will help you .Let me know if it helps !!

Thanks 
Manoj