I've seen that when a related list in a record's detail page surpasses 5 (or something) records, there is a link in the bottom that navigates to the full list of related records and nothing else.

In the instance I'm working on, I get this URL for such related list: <salesforce_url>/a0F?rlid=00N6100000HUcTH&id=a0BQ000000AwSvF

By dissecting that URL I've found that a0F is the prefix of the related object (child of the relationship). 00N6100000HUcTH is the id of the field definition in that object that relates it to its parent. And a0BQ000000AwSvF is the id of the parent itself: The record whose related list I wanna see.

How can I implement a link in a Visualforce page that gets me to this list in a way that works both in the sandbox and production? Do I have to build it manually or does Salesforce provide a shortcut? If I have to build it, does Schema.DescribeFieldResult have an Id field? Can't find documentation for that class.

  • find my updated answer Commented May 23, 2017 at 22:20

2 Answers 2


Key prefix a0F can be achieved by this, replace OBJECT_API_NAME with your desired value.


Following code will help you to getField() from relationship.

Schema.DescribeSobjectResult r = Account.SobjectType.getDescribe();
List<Schema.childRelationship> c = r.getChildRelationShips();

for(schema.childRelationship x:c){
    String name = ''+ x.getChildSObject();
    {   System.debug('getField=' + '' + x.getField());



And to get the Salesforce Id from field, refer this answer How to get the entity ID for a custom field in Apex?

Hopefully, this will help you to achieve your functionality.


If you know the object name you can do it

Schema.DescribeSObjectResult r = CustomObject__c.sObjectType.getDescribe();
String keyPrefix = r.getKeyPrefix();
System.debug('Printing --'+keyPrefix );

Schema.DescribeFieldResult f = Schema.sObjectType.Custom_Object__c.fields.Custom_Field__c; System.debug(f.getRelationshipName());

and build your URL. Hope this helps.

  • How do you get the Id of the field? Does Schema.DescribeFieldResult have a id field? You show getRelationshipName, is it the same? Commented May 23, 2017 at 21:01
  • On VF controller you should have that value. Commented May 23, 2017 at 23:56

You must log in to answer this question.

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