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
Raksha NarayanRaksha Narayan 

'Invalid field recordtype.developername for Case' error while fetching recordtype.developer name

Below is the code snippet:
list<case> clist=[select id,recordtypeId,recordtype.developername from case limit 2];
for(case cs:clist){
    newcase__c bInstance = new newcase__c(); 
    Map<String,newcase_Config__mdt> Mapmetadata = newcase_Config__mdt.getAll();
 for(String mdtMap : Mapmetadata.keySet()){
        String fromField = Mapmetadata.get(mdtMap).From__c; //assume the value is recordtype.developername
        String toField = Mapmetadata.get(mdtMap).to__c; //assume the value is recordtype.developername
        system.debug('@@'+cs.recordtype.developername);
        bInstance.put(toField,cs.get(fromField));    
 system.debug('binstance'+binstance);        
    }
}
Here, from__c is holding the recordtype.developername on the case object and to__c is holding the recordtype.developername on the newcase__c object. In line 9, the fetched recordtype value has to get assigned to newcase__c's recordtype.developername. But I am getting an error as 'Invalid field recordtype.developername for Case'. Is there any way to achieve this?   
Prasad Avala(SFDC-SF)Prasad Avala(SFDC-SF)
@Raksha, Did you try the same query from Developer console to see if its working(Make sure if you have atleast on case avaible that org you are trying)? I tried this in my org and it worked.
Raksha NarayanRaksha Narayan
Yes I tried the same in developer console and it is throwing the error at this line bInstance.put(toField,cs.get(fromField));