Home

Feb 19, 2013

CRM 2011 | Retrieve Roles Using Linked Entity - Inline query

Inline query for linked entity can be used to retrieve roles.
QueryExpression query = new QueryExpression
{
    EntityName = "role",
    ColumnSet = new ColumnSet("name"),
    LinkEntities =
    {
        new LinkEntity
        {
            LinkFromEntityName = "role",
            LinkFromAttributeName = "roleid",
            LinkToEntityName = "systemuserroles",
            LinkToAttributeName = "roleid",
            LinkEntities =
            {
                new LinkEntity
                        {
                            LinkFromEntityName = "systemuserroles",
                            LinkFromAttributeName = "systemuserid",
                            LinkToEntityName = "systemuser",
                            LinkToAttributeName = "systemuserid",
                            LinkCriteria = new FilterExpression
                            {
                                Conditions =
                                {
                                        new ConditionExpression
                                        {
                                            AttributeName = "systemuserid",
                                            Operator= ConditionOperator.Equal,
                                            Values = {userid}
                                        }
                                }
                            }
                        }
            }
        },
    },
};
 

No comments: