I'm writing custom history tracking code, tracking needs to be done for more than 50 fields
All working fine, but instead of record type name , I'm getting record type id, and the same is happening for Account & Owner. Getting id not but not able to get name.
Thinking a lot but not able to find the solution. Here is my code snippet:
// map_Allfields = all fields of object say contact
//loop through all records
For (Contact c : Trigger.new)
{
// loop through fields of contact
for (Schema.SObjectField SobjectFld: map_Allfields.values())
{
Schema.DescribeFieldResult describeResult = SobjectFld.getDescribe();
//If field is of type recordtype, get name instead ID
If (describeResult.getName() == 'RecordTypeId')
{
String recordtypeID = c.get(describeResult.getName())
//get name of Record Type of current record. how ?
system.debug('FieldValue='+ c.recordtype.Name);// not working
}
If (describeResult.getName() == 'OwnerID')
{
String ownerID = c.get(describeResult.getName())
// get Owner name of this of current record
system.debug('FieldValue='+ c.Owner.Name);// not working
}
If (describeResult.getName() == 'AccountID')
{
String AccountID= c.get(describeResult.getName())
// get Account Name of current record
system.debug('FieldValue='+ c.Account.Name);// not working
}
}