Reputation: 906
I'm trying to build a sharepoint BCS connector that grabs data from CRM4. I have it fetching normal attributes from the "contact" entitiy, but I'm not seeing how to retrieve things like related contacts, custom entities or meetings/appointments, etc.
I have read through these:
how to get related entities in dynamics CRM 2011
Retrieve a list of entites from CRM 2011, each with all of their related entities
Microsoft CRM, how do I get all the members of a list using CrmService?
But I can't seem to see any reference to what I am doing. I'm using the normal CRMService web service. I am using the normal request:
var contacts = service.RetrieveMultiple(query);
That only gets me access to the basic attributes, unless I am missing something. If a contact has a few entities related to it (other contacts/meetings), can I grab that from the same query? Or does this require another hit to another entity?
Upvotes: 0
Views: 4661
Reputation: 4520
From what I know (and remember from CRM 4), you have to query each entity independently. On the other hand, you can filter on what you want:
var query = new QueryExpression
{
EntityName = "new_typedecontrat",
ColumnSet = new ColumnSet { AllColumns = true },
Criteria = new FilterExpression
{
FilterOperator = LogicalOperator.And
}
};
var expression2 = new ConditionExpression("new_typedecontratid", ConditionOperator.Equal, campaign.New_TypedecontratId.Id);
query.Criteria.Conditions.Add(expression2);
EntityCollection entitys = CRM.Instance.RetrieveMultiple(query);
try
{
using (var serviceProxy1 = new OrganizationServiceProxy(organizationUri, homeRealmUri, credentials, null))
{
// This statement is required to enable early-bound type support.
serviceProxy1.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
serviceProxy1.Timeout = new TimeSpan(0, 10, 0);
CRMService = serviceProxy1;
return CRMService.RetrieveMultiple(query);
}
}
Does this answer your question?
Upvotes: 1