locked
CRM 4 - Retrieve Users from a Business Unit. RRS feed

  • Question

  • I am looking to get a list of Users associated with a specified Business Unit.

    I have tried RetrieveSubsidiaryUsersBusinessUnitRequest which of course returns Users for the Child Business Units but not for the Parent Business Unit itself.

    I want the Target Business Unit only and not the children or any parents.

    Seems like it should be simple?

    Tuesday, October 19, 2010 11:22 AM

Answers

  • Hello, Gordon.

     

    Try to use following code:

          QueryByAttribute query = new QueryByAttribute();
          query.Attributes = new string[] { "businessunitid" };
          query.ColumnSet = new AllColumns();
          query.EntityName = EntityName.systemuser.ToString();
          query.Values = new object[] { Guid.Empty };
    
          List<BusinessEntity> users = crmservice.RetrieveMultiple(query).BusinessEntities;
    
          foreach (systemuser user in users)
          {
            //here is your code
          }
    
    
    Of course you should replace Guid.Empty with identifier of business unit for which you want to receive all child users.


    Microsoft CRM Freelancer

    My blog (english)
    Мой блог (русскоязычный)
    Tuesday, October 19, 2010 11:38 AM
    Moderator