I'm new to saleforce, I want to make a custom case history component using the CaseHistory object, I do the following SOQL

List <CaseHistory> caseHist = [SELECT Id,
                 FROM CaseHistory WHERE CaseId =: caseId ORDER BY CreatedDate DESC LIMIT 3];

I have three problems:

  1. the field I need the label not the name api
  2. update the component when making any changes (as it is a history component, Case (parent) when making modifications to the case when saving it should be displayed in the case history component (child) since they are on the same page)
  3. there are changes that are made and keeps two records the id of another object and the name

enter image description here

enter image description here

1 Answer 1


This is how you can get the field names:

String type= 'MyCustomObject__c';  // Say,this is my object

Map<String, Schema.SObjectType> schemaMap = Schema.getGlobalDescribe();
    Schema.SObjectType leadSchema = schemaMap.get(type);
    Map<String, Schema.SObjectField> fieldMap = leadSchema.getDescribe().fields.getMap();

for (String fieldName: fieldMap.keySet()) {  
        String mylabel;
          //It provides to get the object fields label.
         mylabel = fieldMap.get(fieldName).getDescribe().getLabel();

As for your other two issues, can I have some more context/info, please!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .