You need to sign in to do that
Don't have an account?

Dynamic sobject typecasting issue
Hi,
I am trying to fetch a field value from a custom object. Currently am storing custom object data in a sObject. when i try to fetch some related field value of custom object. it is throwing me error as invalid field.
if i try to fetch field value belongs to custom object, it is providing correctly.
for(At_Risk_Request__c AtRiskRecords : mapMainObject.values()) // Taking atRisk record { sObject dynObject= Schema.getGlobalDescribe().get('At_Risk_Request__c').newSObject() ; //At_Risk_Request__c dynObject = new At_Risk_Request__c(); dynObject= mapMainObjectData.get(AtRiskRecords.Id); system.debug('GlobalREgion+++++'+String.valueOf(dynObject.get(CustomerAccount__r.Global_Region__c)));
At_Risk_Request__c is a Child object and CustomerAccount is parent object (Account).
Just answered on last post