如何使用VF或APEX获取相关列表,当我们通过URL传递ID和对象时,Ex假设我发送Account对象和ID,我应该只获取与Account对象相关的列表,但不能获取Account details 。如果我使用APEx:详细信息我将获得帐户和它的相关列表,但我只需要相关列表。仅在salesforce中使用的相关列表
@Ivan这里的代码
控制器
Public Class CustomRelatedList{
public String objectType {get; set;}
public Set<String> chsobject1 {get;set;}
public sobjecttype chsobject {get;set;}
public sObject[] data {get; set;}
public CustomRelatedList() {
chsobject1 = new Set<String>();
}
public void CustomRelatedList1() {
//get URL parameters
//的objectType = ApexPages.currentPage()getParameters()得到( 'urlparm')。;
objectType = ‘Account’; //for testing purpose will get object type & Id from URL
Map<String , Schema.SObjectType> globalDescription = Schema.getGlobalDescribe();
Schema.sObjectType sObjType = globalDescription.get(objectType);
Schema.DescribeSObjectResult r1 = sObjType.getDescribe();
List<Schema.ChildRelationship> C = r1.getChildRelationships();
for (Schema.ChildRelationship C1:C) {
chsobject = C1.getChildSObject();
chsobject1.add(String.valueof(chsobject));
}
}
}
VF page
<apex:page controller="CustomRelatedList" >
<apex:repeat value="{!chsobject1}" var="a" >
<apex:relatedList list="{!a}" subject="{!$CurrentPage.parameters.id}" />
</apex:repeat>
</apex:page>
我想显示的ID(不只是名称)的所有相关的清单,但参数列表中只需要文字
谢谢它的工作:-) – user3589895
酷:)请考虑在几天的时间接受答案。这样,你可以给予其他人几天更多的聪明才智,但最终这些问题很有可能会被“忽略”。 – eyescream