So I need to access the value of an email field which is set by a workflow. However this needs to be done through a lookup relasionship as seen below.
Customobj1__c newRecord = new Customobj1__c(); newRecord.populatefields = 'ect'; sObject newobject; newObject = newRecord;
Customobj1__c (child) has a lookup relasionship to Customobj2__c (parent). So if I want to get a value of Customobj2__c field I do the following
To access a value of a field in Apex I use the following (for picklist field):
Schema.sObjectType objType = objObject.getSObjectType(); Schema.DescribeSObjectResult objDescribe = objType.getDescribe(); map < String, Schema.SObjectField > fieldMap = objDescribe.fields.getMap(); list < Schema.PicklistEntry > values = fieldMap.get(fld).getDescribe().getPickListValues();
The issue I am having is since I have a lookup relasionship, I cant use the sObject methods. I believe I need to specify that the sObjectType is of Customobj2__c (to access the email field) and then cast it back to sObject to use the rest of the methods. Once I have a map of all the fields in Customobj2__c, I can use fieldMap.get(emailfield__c) but how do I actually obtain the value in this field?
I tried the following but it says getSObjectType() is not recognized since its of type Customobj1__c and not sObject