In general we use the Update method to update the fields in MSCRM. But, we cannot update the owner of an entity using update method. To update the owner, we have to make use of AssignRequest.
AssignRequest req = new AssignRequest();
SecurityPrincipal assignee = new SecurityPrincipal();
AssignRequest req = new AssignRequest();
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type =
SecurityPrincipalType.User; //User or Queue
assignee.PrincipalId = ownerID; //crm userid to whom we assign
// Request changes depending on the entity. For account, it is TargetOwnedAccount
// Request changes depending on the entity. For account, it is TargetOwnedAccount
TargetOwnedLead target = new
TargetOwnedLead();
target.EntityId = leadID; //Id of the lead record whose owner has to be updated
req.Assignee = assignee;
req.Assignee = assignee;
req.Target = target;
_service.Execute(req); //_service is the crm service
No comments:
Post a Comment