【问题标题】:How to retrieve field from custom master object?如何从自定义主对象中检索字段?
【发布时间】:2019-05-30 05:12:12
【问题描述】:

我正在尝试编写一个自定义对象,并且必须从自定义对象 Course Master(master) 检索一个自定义相关字段以详细了解对象培训交易。此代码显示错误

 List<List<String>> strList = new List<List<String>>();
    List<Training_deal__c> td = [select name,   Course_master__r.course__c from Training_deal__c];

    for(Training_deal__c t : td){
        List<String> tempList = new List<String>();
        tempList.add('Training Deals');
        tempList.add(t.name);
        tempList.add(t.course__c);
        strList.add(tempList);
    }

【问题讨论】:

    标签: salesforce apex soql


    【解决方案1】:

    试试这个

    tempList.add(t.Course_master__r.course__c);
    

    【讨论】:

    • 没有用。给出错误。错误错误:编译错误:变量不存在:Course_master__r 在第 11 行第 24 列
    【解决方案2】:

    我试着喜欢这个,它工作正常

    List<List<String>> strList = new List<List<String>>();
    List<Training_deal__c> td = [select name,   Course_master__r.course__c from Training_deal__c];
    
    for(Training_deal__c t : td){
        List<String> tempList = new List<String>();
        tempList.add('Training Deals');
        tempList.add(t.name);
        tempList.add(t.Course_master__r.course__c);
        strList.add(tempList);
    }
    

    【讨论】:

      猜你喜欢
      • 2019-02-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-26
      • 2017-09-02
      • 1970-01-01
      相关资源
      最近更新 更多