简体   繁体   中英

How to retrieve field from custom master object?

I am trying to write a custom object and have to retrieve one custom related field from custom object Course Master(master) to detail object Training deals. This code is showing error

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

尝试这个

tempList.add(t.Course_master__r.course__c);

I tried to like this and it is working properly

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM