locked
CRM 2016 Online: Is it possible to set Logical Operator OR between 2 Linked Entities RRS feed

  • Question

  • I have a scenario where I need to set Logical operator OR between 2 Linked Entities. Is it possible to set OR operator between 2 linked entities as shown in the below sample select query

    select systemuserid from systemuser

    where idisabled=0 AND(LinkedEntity[0] OR LinkedEntity[1])

    In the below highlighted linked entities default it is taking AND operator, can any one help how to setup OR operator between these.

    Below is the Actual Query Expression that I am using, it is working; however it is using AND operator default need to change OR.

    QueryExpression userquery = new QueryExpression("systemuser");
                userquery.NoLock = true;
                userquery.Distinct = true;
                userquery.ColumnSet = new ColumnSet("systemuserid", "fullname");
                userquery.Criteria.AddCondition("isdisabled", ConditionOperator.Equal, false);
    
                LinkEntity elink = new LinkEntity("systemuser", "new_employee", "new_employee", "new_employeeid", JoinOperator.Inner);
                userquery.LinkEntities.Add(elink);
                
                    LinkEntity culink = new LinkEntity("systemuser", "connection", "systemuserid", "record2id", JoinOperator.Inner);
                    userquery.LinkEntities.Add(culink);
    
                LinkEntity celink = new LinkEntity("new_employee", "connection", "new_employeeid", "record2id", JoinOperator.Inner);
                elink.LinkEntities.Add(celink);
    
                LinkEntity crlink = new LinkEntity("connection", "connectionrole", "record2roleid", "connectionroleid", JoinOperator.Inner);
                crlink.LinkCriteria.Conditions.Add(new ConditionExpression("category", ConditionOperator.Equal, 206490001));
                celink.LinkEntities.Add(crlink);
    
                    culink.LinkEntities.Add(crlink);
    
                celink.LinkCriteria.AddFilter(LogicalOperator.And);
    
                LinkEntity olink = new LinkEntity("connection", "opportunity", "record1id", "opportunityid", JoinOperator.Inner);
                olink.LinkCriteria.Conditions.Add(new ConditionExpression("opportunityid", ConditionOperator.Equal, context.PrimaryEntityId));
                celink.LinkEntities.Add(olink);
    
                    culink.LinkEntities.Add(olink);
    
                var FinalResult = ImperService.RetrieveMultiple(userquery);


    Madhu M.


    • Edited by Madhu_M Friday, November 18, 2016 9:00 PM added screenshot
    Friday, November 18, 2016 8:59 PM

All replies