开发者

Retrieving related entities using RetrieveMultipleRequest

I have an entity called Invoice and an entity called InvoiceItem.

There is a one to many relationship called new_invoice_invoiceitem.

There is a LookupAttribute in InvoiceItem called new_parent_invoice_invoiceitem.

I am trying to retrieve the InvoiceItems that are related to the Invoice with a particular ID using the following code:

QueryExpression query = new QueryExpression();
query.EntityName = "new_invoiceitem";
query.ColumnSet = new AllColumns();
ConditionExpression condition = new ConditionExpression();
condition.AttributeName = "new_parent_invoice_invoiceitem";
condition.Values = new object [] { new Guid("fe1009cc-e034-49d5-bc59-ab4c3091a6f9") };
condition.Operator = ConditionOperator.Equal;

Fil开发者_JAVA百科terExpression filter = new FilterExpression();
filter.AddCondition(condition);
query.Criteria = filter;

RetrieveMultipleRequest request = new RetrieveMultipleRequest();
request.Query = query;

RetrieveMultipleResponse response = (RetrieveMultipleResponse)crmService.Execute(request);
BusinessEntityCollection bec = response.BusinessEntityCollection;

The code runs without errors but the BusinessEntityCollection is always empty even though there are records in Dynamics.

Any idea what I'm doing wrong?

Thanks,

David


Try setting request.ReturnDynamicEntities = true

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜