I am very new to apex, I am trying to understand apex code written by someone else. Its retrieving opportunity data. It gets all the fields except opportunity contact role. Its always empty, even though there is data in it.
It calls the opportunity selector from the service class
Opportunity opp = cq.Opportunities.GetByIdWithOCR(new Set{opportunityId})[0];
in the opportunitySelector.apxc
public List<Opportunity> GetByIdWithOCR(Set<Id> idSet) {
return (List<Opportunity>) GetQueryFactory()
.WithCriteria(cq_Criteria.ValueIn(Opportunity.Id, idSet))
.WithRelatedField(Opportunity.AccountId, Account.Name)
.WithRelatedField(Opportunity.AccountId, Account.BillingStreet)
.WithRelatedField(Opportunity.AccountId, Account.BillingCity)
.WithRelatedField(Opportunity.AccountId, Account.BillingState)
.WithRelatedField(Opportunity.AccountId, Account.BillingPostalCode)
.WithRelatedField(Opportunity.AccountId, Account.BillingCountry)
.WithChildQuery(
cq.OpportunityContactRoles.GetQueryFactory()
.WithCriteria(cq_Criteria.Equals(OpportunityContactRole.Role, 'Decision Maker'))
.WithRelatedField(OpportunityContactRole.ContactId, Contact.Name)
.WithRelatedField(OpportunityContactRole.ContactId, Contact.Phone)
.WithRelatedField(OpportunityContactRole.ContactId, Contact.Email))
.Execute();
}
all the values are there but contact role is empty. Please advice