Skip to main content
formatting
Source Link
crmprogdev
  • 41k
  • 9
  • 58
  • 116

How to get an hierarchy of all objects dynamically through schema code in Salesforce

How to get a hierarchy of all objects dynamically through schema code in Salesforce I have code like below.

Set<String> strForRelatedObjects = new Set<String>();
Schema.SObjectType objectType = schema.getGlobalDescribe().get('child__c');

for(Schema.SobjectField strFld: objectType.getDescribe().fields.getMap().Values()){
    if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE){
        strForRelatedObjects.add(string.valueof(strFld.getDescribe().getReferenceTo()).substringBetween('(',')'));         
    }
}

I want to fetch all parent object to object  (Overall hierarchy). And aboveAbove code should be in a position toable get all the related objects to objects I want to fetch

How to get an hierarchy of all objects dynamically through schema code in Salesforce

How to get a hierarchy of all objects dynamically through schema code in Salesforce I have code like below.

Set<String> strForRelatedObjects = new Set<String>();
Schema.SObjectType objectType = schema.getGlobalDescribe().get('child__c');

for(Schema.SobjectField strFld: objectType.getDescribe().fields.getMap().Values()){
    if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE){
        strForRelatedObjects.add(string.valueof(strFld.getDescribe().getReferenceTo()).substringBetween('(',')'));         
    }
}

I want to fetch all parent object to object(Overall hierarchy). And above code should be in a position to get all the related objects to objects I want to fetch

How to get hierarchy of all objects dynamically through schema code

How to get a hierarchy of all objects dynamically through schema code in Salesforce I have code like below.

Set<String> strForRelatedObjects = new Set<String>();
Schema.SObjectType objectType = schema.getGlobalDescribe().get('child__c');

for(Schema.SobjectField strFld: objectType.getDescribe().fields.getMap().Values()){
    if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE){
        strForRelatedObjects.add(string.valueof(strFld.getDescribe().getReferenceTo()).substringBetween('(',')'));         
    }
}

I want to fetch all parent object to object  (Overall hierarchy). Above code should be able get all the related objects I want to fetch

How to get hirarchyan hierarchy of all objects dynamically through schema code in salesforceSalesforce

How to get hirarchya hierarchy of all objects dynamically through schema code in salesforceSalesforce I have code like below.

set<string>Set<String> strForRelatedObjects = new set<string>Set<String>();
Schema.SObjectType objectType = schema.getGlobalDescribe().get('child__c');

for(Schema.SobjectField strFld: objectType.getDescribe().fields.getMap().Values()){
    if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE){
        strForRelatedObjects.add(string.valueof(strFld.getDescribe().getReferenceTo()).substringBetween('(',')')); 
                
    }
}

I want to fetch all parent object to object(Overall hirarchyhierarchy).and And above code should be in a position to get all the related objects to to objects iI want to fetch

How to get hirarchy of all objects dynamically through schema code in salesforce

How to get hirarchy of all objects dynamically through schema code in salesforce I have code like below.

set<string> strForRelatedObjects = new set<string>();
Schema.SObjectType objectType = schema.getGlobalDescribe().get('child__c');

for(Schema.SobjectField strFld: objectType.getDescribe().fields.getMap().Values()){
    if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE){
        strForRelatedObjects.add(string.valueof(strFld.getDescribe().getReferenceTo()).substringBetween('(',')')); 
                
    }
}

I want to fetch all parent object to object(Overall hirarchy).and above code should in position to get all the related objects to to objects i want to fetch

How to get an hierarchy of all objects dynamically through schema code in Salesforce

How to get a hierarchy of all objects dynamically through schema code in Salesforce I have code like below.

Set<String> strForRelatedObjects = new Set<String>();
Schema.SObjectType objectType = schema.getGlobalDescribe().get('child__c');

for(Schema.SobjectField strFld: objectType.getDescribe().fields.getMap().Values()){
    if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE){
        strForRelatedObjects.add(string.valueof(strFld.getDescribe().getReferenceTo()).substringBetween('(',')'));         
    }
}

I want to fetch all parent object to object(Overall hierarchy). And above code should be in a position to get all the related objects to objects I want to fetch

fixed code formatting, removed irrelevant tag (scratch-org)
Source Link
Derek F
  • 64.1k
  • 15
  • 55
  • 104

How to get hirarchy of all objects dynamically through schema code in salesforce I have code like below.

set strForRelatedObjects = new set();

set<string> strForRelatedObjects = new set<string>();
Schema.SObjectType objectType = schema.getGlobalDescribe().get('child__c');
     
for(Schema.SobjectField strFld: objectType.getDescribe().fields.getMap().Values()){
        
        if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE){
            strForRelatedObjects.add(string.valueof(strFld.getDescribe().getReferenceTo()).substringBetween('(',')')); 
            
       
    }
    }.

I want to fetch all parent object to object(Overall hirarchy).and above code should in position to get all the related objects to to objects i want to fetch

How to get hirarchy of all objects dynamically through schema code in salesforce I have code like below.

set strForRelatedObjects = new set();

  Schema.SObjectType objectType = schema.getGlobalDescribe().get('child__c');
    for(Schema.SobjectField strFld: objectType.getDescribe().fields.getMap().Values()){
        
        if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE){
            strForRelatedObjects.add(string.valueof(strFld.getDescribe().getReferenceTo()).substringBetween('(',')')); 
            
          }
    }.

I want to fetch all parent object to object(Overall hirarchy).and above code should in position to get all the related objects to to objects i want to fetch

How to get hirarchy of all objects dynamically through schema code in salesforce I have code like below.

set<string> strForRelatedObjects = new set<string>();
Schema.SObjectType objectType = schema.getGlobalDescribe().get('child__c');
 
for(Schema.SobjectField strFld: objectType.getDescribe().fields.getMap().Values()){
    if(strFld.getDescribe().getType() == Schema.DisplayType.REFERENCE){
        strForRelatedObjects.add(string.valueof(strFld.getDescribe().getReferenceTo()).substringBetween('(',')')); 
                 
    }
}

I want to fetch all parent object to object(Overall hirarchy).and above code should in position to get all the related objects to to objects i want to fetch

Source Link
Loading