Strange problem in plugin RRS feed

  • Question

  • Hello Everyone,


    I'm facing a wierd problem in one of my plugins. The plugin is registered to fire on update of my Entity1. If the status of the record is "Approved", I'm changing the business unit of the user from BUDefault to BU1 and also assigning him a role Role1 (belongs to BU1). The problem is that I'm getting an exception "The role does not belong to the business unit of the user". I verified it multiple times that Role1 belongs to the BU1.


    The error does not occur when I debug statement by statement. My doubt is, whether SetBusinessSystemUserResponse

    works synchronously or asynchronously?


    Below is my code:


    CrmSdk.SetBusinessSystemUserRequest systemuserrequest = new CrmSdk.SetBusinessSystemUserRequest();

    // Set the properties of the request object.

    systemuserrequest.BusinessId = new Guid(sBusinessunitId);

    CrmSdk.SecurityPrincipal assignee = new CrmSdk.SecurityPrincipal();

    assignee.PrincipalId = new Guid(str_User);

    systemuserrequest.ReassignPrincipal = assignee;

    systemuserrequest.UserId = new Guid(str_User);

    // Set the new Bussiness Unit

    CrmSdk.SetBusinessSystemUserResponse assigned = (CrmSdk.SetBusinessSystemUserResponse)argCrmService.Execute(systemuserrequest);




    CrmSdk.AssignUserRolesRoleRequest assign = new CrmSdk.AssignUserRolesRoleRequest();

    // Set the properties of the request object.

    assign.UserId = new Guid(str_User);


    // Set the ID of a role that is in the same business unit as the user.

    Guid[] sGuid = new Guid[] { new Guid(sPostRoleid) };

    assign.RoleIds = sGuid;

    // Execute the request.

    CrmSdk.AssignUserRolesRoleResponse assigned1 = (CrmSdk.AssignUserRolesRoleResponse)argCrmService.Execute(assign);


    Any help towards this would be highly appreciated!


    Thanks & Regards,



    Tuesday, January 6, 2009 1:38 PM

All replies

  • Hi,


    There is no indication that the request is async. The next logical step is to check whether the SetBusinessSystemUserRequest fires another message e.g. assign or GrantAccess and tries to complete the AssignUserRolesRoleRequest there.



    Tuesday, January 6, 2009 3:01 PM