1

I have below piece of code where I want to traverse to details from the base query on master object. But I am getting error Like :

Error

Compile Error: Didn't understand relationship 'Account_List_Item_vod__r' in FROM part of query call. If you are attempting to use a custom relationship, be sure to append the '__r' after the custom relationship name. Please reference your WSDL or the describe call for the appropriate names

Apex code

Map<Id,set<Id>> MapOfAcctListItem = new Map<Id,Set<Id>>();

              for(Account_List_vod__c cpc : [select Access_vod__c,Display_Order_vod__c,Icon_Name_vod__c,Id,Name,OwnerId, 
                                                        (select ID,Account_vod__c,External_ID_vod__c 
                                                         from Account_List_Item_vod__r) 
                                                 from Account_List_vod__c 
                                                 where OwnerId in :MapOfTierObj.keyset()
                                                 And Name =:ListName])
        {
            if(!cpc.Account_List_Item_vod__r.isempty())
            {
                if(!MapOfAcctListItem.containsKey(cpc.OwnerId)){
                    MapOfAcctListItem.put(cpc.OwnerId,cpc.Account_List_Item_vod__r);}
                else{    
                MapOfAcctListItem.get(cpc.OwnerId).addAll(cpc.Account_List_Item_vod__r);}
            }
        }

Can someone please let me know where I go wrong here?

2

You can get the specific API Name of the child relationship using describes. Run this script via Execute Anonymous, substituting the proper names for parent and child objects:

for (ChildRelationship relation : SObjectType.Parent__c.getChildRelationships())
    if (relation.getChildSobject() == Child__c.sObjectType)
        system.debug(relation.getRelationshipName());

In this case you would change Parent__c to Account_List_vod__c and change Child__c to Account_List_Item_vod__c, though I'm making a guess at the name of the child object.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.