none
Creating BusinessUnit through CRM SDK and assigning CRM Roles

    Question

  • Guid newbusid = new Guid();

    businessunit

    newbusunit = new businessunit();

    newbusunit.name = Name;

    newbusunit.parentbusinessunitid = new Lookup();

    newbusunit.parentbusinessunitid.Value = ParentBusid;

    // Execute the request.

    try

    {

    newbusid = _Service.Create(newbusunit);

    }

    catch

    (System.Web.Services.Protocols.SoapException ex)

    {

    //Cursor.Current = Cursors.Default;

    string

    error;

    }

     

     

    Hi all,

    above is the code which i am using to create the business unit , it is woking fine and i am assigning the proper roles and i check the user it is having correct business unit and proper roles.

    i have a requirment of moving changing the business unit from one user to other, even that is working fine with proper roles

    below code i am using for chaning the business unit.

    when i see the user businessunit getting changed properly with apporiate roles.

    but when i see the contact and account both the users with different business unit can see the data(account and contact's)

    same thing when i create business unit through CRM and assign the bussiness unit through CRM --> users --> Actions--> change Business unit, with same roles it is wroking fine.

    one user cannot see the account and contact of other business unit.

    what could be the problem in this code ?

    can any one help ?

    SetParentBusinessUnitRequest request = new SetParentBusinessUnitRequest();

    request.BusinessUnitId =BuGuid;

    request.ParentId = ParentBusid;

    try

    {

     

    SetParentBusinessUnitResponse

    chgParentbus = (SetParentBusinessUnitResponse)_Service.Execute(request);

    }

    catch

    (System.Web.Services.Protocols.SoapException ex)

    {

    string

    error;

    }

    Monday, November 16, 2009 1:21 PM