【问题标题】:Referencing a custom field id引用自定义字段 ID
【发布时间】:2017-05-16 05:29:18
【问题描述】:

我有两个自定义对象,类别和案例,我将类别设置为父对象。类别中的列 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',但在Category中它是'0'和'1'。

视觉页面

          <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;
    } 

我想根据选定的Category_ID 值获得不同的案例选择列表。 谁能告诉我为什么?因为我想基于相同的Category_ID 值运行一些查询。

【问题讨论】:

    标签: salesforce apex custom-object


    【解决方案1】:

    我认为您没有使用for 循环在selectList 中添加Category_Id__c

    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));
            }
    

    【讨论】:

      猜你喜欢
      • 2017-08-29
      • 2018-07-03
      • 2015-02-22
      • 1970-01-01
      • 2019-01-01
      • 2018-12-12
      • 1970-01-01
      • 2014-09-14
      • 1970-01-01
      相关资源
      最近更新 更多