1

As I have a functionality where I have a Vf page for classic & a lightning component for lex and I need show the child object of selected object. So have used below code for this & it showing different objects in classic & lighting.

For example I want to get child records for the Contact Object. when I check the list of child objects on visualforce page it does not show me Opportunity but in lightning component it does. I also Don't want that opportunity as there is no custom relationship between contact & opportunity

Please note that have used same code for both VF page & lightning component

Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe(); 
for(Schema.ChildRelationship child :gd.get('contact').getDescribe().getChildRelationships()){
            
     DescribeSObjectResult childDescribe = child.getChildSObject().getDescribe();
     System.debug('ojb=>'+childDescribe.getName());
}
3
  • 1
    Please check if the VF page and class have version > 46. There is a lookup to contact on Opportunity which is stamped to the primary contact of that opportunity. developer.salesforce.com/docs/atlas.en-us.api.meta/api/…
    – manjit5190
    Jul 30, 2020 at 14:22
  • Thanks for your reply. You are right, page & class have version 37. have changed it now to 48. & it showing opportunity as well in VF page. But the relationship field between opportunity & contact is ContactId which is hidden. I don't want such hidden lookups. Jul 30, 2020 at 14:31
  • Well, I would say to explicitly exclude it if you don't want it or use the component with API version < 46 (It would be a security issue and you wouldn't be able to access any new features)
    – manjit5190
    Jul 30, 2020 at 14:34

1 Answer 1

2

Please check if the VF page and class have version > 46. There is a lookup to contact on Opportunity which is stamped to the primary contact of that opportunity. See here

If you don't want the relationship to come in a describe call then, you will need to explicitly exclude it OR use the components with API version < 46 (It would be a security issue and you wouldn't be able to access any new features)

You must log in to answer this question.

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