Quantcast
Viewing all articles
Browse latest Browse all 130

Assigning Accounts using the CRM webservice

Unfortunately you cant just change the ownerD value on a record from a update call if you would like to re assign a record. you have to use the AssignRequest Class to carry this out for you, i would assume that this is due to the security model setup on the CRM system.

Pasted a snippet, from some code i used on a plugin i was working on.

// Create the SecurityPrincipal object.
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;

// PrincipalId is some known Guid belonging to the user or team that will own this record.
assignee.PrincipalId = new Guid("INSERT GUID OF THE USER YOU WANT TO ASSIGN THE RECORD TO");

// Create the target object for the request.
TargetOwnedAccount target = new TargetOwnedAccount();

// Set the properties of the target object.
// EntityId is some known Guid belonging to the account that is being assigned to the user.
target.EntityId = new Guid("INSERT GUID OF THE ACCOUNT YOU WOULD LIKE TO HAVE REASSIGNED");

// Create the request object.
AssignRequest assign = new AssignRequest();

// Set the properties of the request object.
assign.Assignee = assignee;
assign.Target = target;

// Execute the request.
AssignResponse assignResponse = (AssignResponse)service.Execute(assign);

Make sure you have set up the correct permissions on the users involved in the reassignment or this procedure will fail.

Enjoy

Jonathan


Viewing all articles
Browse latest Browse all 130

Trending Articles