Showing posts with label SecurityPrinical. Show all posts
Showing posts with label SecurityPrinical. Show all posts

Wednesday, October 1, 2008

Update Account Ownership

With help of this code snippet you can update Account ownership programatically.

TargetOwnedAccount target = new TargetOwnedAccount();
// Account Id for which you want to update ownership
target.EntityId = accountGuid;

systemuser objSystemUser = new systemuser();

// Set SystemUser which you want to set as a owner for account
objSystemUser = (systemuser)becSystemUser.BusinessEntities[0];
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;

// Set fetched user id which we want to set as owner
assignee.PrincipalId = objSystemUser.systemuserid.Value;

AssignRequest asgRequest = new AssignRequest();
asgRequest.Assignee = assignee;
asgRequest.Target = target;
AssignResponse asgResponse = (AssignResponse)objCRMService.Execute(asgRequest);