我有两个自定义对象,Category和Case,我将category设置为parent。类别中的列Category_ID由自定义对象Case引用。我在开发者控制台中执行了两个查询
SELECT Category_ID__c,id,Name FROM Category__c SELECT Category_ID__c,id,Name FROM Case__c 我发现Case中Category_ID的价值就像是' a0D' F000001MmjUae'和' a0D' F000001MmjUde',但在类别中它' 0' 0和' 1'。
VisualPage
guard let
我希望根据选定的 <apex:outputLabel value="Category" />
<apex:selectList value="{!categoryType}" size="1">
<apex:selectOptions value="{!items}"/>
</apex:selectList>
<apex:outputLabel value="Case" />
<apex:selectList value="{!caseId}" size="1">
<apex:selectOptions value="{!items2}"/>
</apex:selectList>
//From here is Controller
public String categoryType{set;get;}
public List<SelectOption> getItems(){
List<selectoption> mlst = new List<selectoption>();
for(VirtualCaseCategory__c m: [SELECT Category_ID__c, Name FROM VirtualCaseCategory__c]){
mlst.add(new selectoption(m.Id,m.Name));
}
return mlst;
}
public List<SelectOption> getItems2(){
List<selectoption> mlst = new List<selectoption>();
for(VirtualCaseCases__c m: [SELECT Category_ID__c, Name FROM VirtualCaseCases__c WHERE Category_ID__c =:categoryType]){
mlst.add(new selectoption(m.Id,m.Name));
}
return mlst;
}
值获得不同的Case selectList。
谁能告诉我为什么?因为我想基于相同的Category_ID
值运行一些查询。
答案 0 :(得分:0)
我认为您未使用Category_Id__c
循环在selectList
中添加for
。
for(VirtualCaseCategory__c m: [SELECT Category_ID__c, Name FROM VirtualCaseCategory__c]){
// insert Category_ID__c in the select option
mlst.add(new selectoption(m.Category_ID__c,m.Name));
}
其他for
循环
for(VirtualCaseCases__c m: [SELECT Category_ID__c, Name FROM VirtualCaseCases__c WHERE Category_ID__c =:categoryType]){
// Same here as well
mlst.add(new selectoption(m.Category_ID__c,m.Name));
}