Get All Users Based on Business Unit -MS CRM 2011

This blog is about getting all CRM users based on business unit ID.

 

private EntityCollection RetrieveUserBasedOnBusinessUnit(IOrganizationService _CrmService, Guid BUId)

{

     QueryExpression _Query = new QueryExpression

     {

         EntityName = "systemuser",

         ColumnSet = new ColumnSet(true),

         Criteria =

         {

             Conditions =

                     {

                         new ConditionExpression

                         {

                             AttributeName="businessunitid",

                             Operator=ConditionOperator.Equal,

                             Values={BUId}

                         }

                     }

         }

     };

     return _CrmService.RetrieveMultiple(_Query);

}

Hope this will help someone.

HIMBAP
We are expert in Microsoft Power Platform.