In this article , I am going to explain, how to assign a record to specific user or team using AssignRequest class
Namespace need to Include
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Discovery;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Crm.Sdk.Messages;
Complete Code
public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete)
{
OrganizationServiceProxy _serviceProxy;
using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri,
serverConfig.HomeRealmUri,
serverConfig.Credentials,
serverConfig.DeviceCredentials))
{
_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
_service = (IOrganizationService)_serviceProxy;
Guid _accountId = new Guid("4d36e97d-e325-11ce-bfc1-08002be10318");
Guid _teamId = new Guid("5d46e97d-f325-33ce-cdc1-09002be10318");
// Assign the account to a team.
AssignRequest assignRequest = new AssignRequest()
{
Assignee = new EntityReference
{
LogicalName = Team.EntityLogicalName,
Id = _teamId
},
Target = new EntityReference(Account.EntityLogicalName, _accountId)
};
_service.Execute(assignRequest);
}
}
Namespace need to Include
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Query;
using Microsoft.Xrm.Sdk.Discovery;
using Microsoft.Xrm.Sdk.Client;
using Microsoft.Crm.Sdk.Messages;
Complete Code
public void Run(ServerConnection.Configuration serverConfig, bool promptForDelete)
{
OrganizationServiceProxy _serviceProxy;
using (_serviceProxy = new OrganizationServiceProxy(serverConfig.OrganizationUri,
serverConfig.HomeRealmUri,
serverConfig.Credentials,
serverConfig.DeviceCredentials))
{
_serviceProxy.ServiceConfiguration.CurrentServiceEndpoint.Behaviors.Add(new ProxyTypesBehavior());
_service = (IOrganizationService)_serviceProxy;
Guid _accountId = new Guid("4d36e97d-e325-11ce-bfc1-08002be10318");
Guid _teamId = new Guid("5d46e97d-f325-33ce-cdc1-09002be10318");
// Assign the account to a team.
AssignRequest assignRequest = new AssignRequest()
{
Assignee = new EntityReference
{
LogicalName = Team.EntityLogicalName,
Id = _teamId
},
Target = new EntityReference(Account.EntityLogicalName, _accountId)
};
_service.Execute(assignRequest);
}
}
No comments:
Post a Comment
Note: only a member of this blog may post a comment.