I've been trying for a bit now to get a way to link a phonecall to a contact within a Query Expression. I don't think I'm doing my Link Entities correctly.
Here is my query expression. Where am I going wrong?
using Microsoft.Crm.Sdk.Messages.Samples;
using Microsoft.Xrm.Sdk.Query.Samples;
QueryExpression qExpression = new QueryExpression("phonecall")
{
ColumnSet = cs,
LinkEntities =
{
new LinkEntity()//"phonecall", "activity", "activityid", "activityid", JoinOperator.Inner)
{
EntityAlias = "ap",
LinkFromEntityName= "phonecall",
LinkFromAttributeName = "activityid",
LinkToEntityName = "activitypointer",
LinkToAttributeName = "activityid",
JoinOperator = JoinOperator.Inner
},
new LinkEntity()//"phonecall", "activity", "activityid", "activityid", JoinOperator.Inner)
{
EntityAlias = "app",
LinkFromEntityName= "activitypointer",
LinkFromAttributeName = "activityid",
LinkToEntityName = "activityparty",
LinkToAttributeName = "activityid",
JoinOperator = JoinOperator.Inner,
LinkCriteria = new FilterExpression
{
Conditions =
{
new ConditionExpression("ParticipationTypeMask", ConditionOperator.Equal, 2),
}
}
},
new LinkEntity()
{
EntityAlias = "con",
Columns = new ColumnSet("fullname","contactid"),
JoinOperator = JoinOperator.Inner,
LinkFromEntityName = "activityparty",
LinkFromAttributeName = "partyid",
LinkToEntityName = "contact",
LinkToAttributeName = "contactid"
}
}
};