Jun 17, 2013

Assigning a User or Team

Just though of posting an important code snippet on how to assign a user to a record. Please find a sample code.

using Microsoft.Crm.Sdk.Messages;

AssignRequest assignAcc = new AssignRequest
{
    Assignee = new EntityReference("systemuser", new Guid("5BA4B404-EF87-4F11-8492-D437823E18AB")),
    Target = new EntityReference("opportunity", new Guid("F01F4B23-A996-4519-8395-C7428DDEA8DB"))
};
service.Execute(assignAcc);

Here Target entity is the entity type of the record we are going to assign a new user.  In my case, its opportunity. Here I am assigning a user but we can use same code for assigning a team. In that case Assignee will have to change accordingly. (team instead of systemuser)

No comments:

Post a Comment