0

I have requirement to display few related list based on the profile for that i have design the separate page for that.

Below is the apex code to get the Related child names ie.. "relatedListNames".

Schema.DescribeSObjectResult R = <ObjectName>.SObjectType.getDescribe();
    List<Schema.ChildRelationship> relatedLsts= R.getChildRelationships(); 
    relatedListNames=new  Set<String>();
    for( Schema.ChildRelationship childObject :relatedLsts){
        System.debug('childObject *** : '+childObject);
        relatedListNames.add(String.valueOf(childObject.getChildSObject()));
    }

Now i have to display those related names in my visual force page as mentionedin below lines, but i am getting an error "Literal value is required for attribute list in <apex:relatedList> in * at line * column *: Markup" when i try to save the visual force page.

 <apex:repeat value="{!relatedListNames}" var="relatedListName" >
        <apex:relatedList list="{!relatedListName}" /> 
 </apex:repeat>

Can anyone help me with solving , how can i display related list dynamically in visual force page.

1

You want to display related list dynamically on vf page. For this you have to create a dynamic VF page.

This question has been asked here already:

<apex:relatedList list="{!DontExistInAllOrgs__c}"/ > only solveable with Dynamic Vf components?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.