Hi All,
Please find the Code for the Assign Team Login in C#
SnapShot:
Plugin :
Please find the Code for the Assign Team Login in C#
SnapShot:
Plugin :
protected void ExecutePreTaskAssign(LocalPluginContext localContext)
{
if (localContext == null)
{
throw new ArgumentNullException("localContext");
}
IPluginExecutionContext context = localContext.PluginExecutionContext;
IOrganizationService service = localContext.OrganizationService;
try
{
//Check if context contains the "Target" parameter and that it
is an EntityReference
is an EntityReference
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is EntityReference)
context.InputParameters["Target"] is EntityReference)
{
EntityReference targetEntity =
(EntityReference)context.InputParameters["Target"];
//Check if the entity type is Task
if (targetEntity.LogicalName != "task")
{ return; }
//Check if context contains the "Assignee" parameter
if (context.InputParameters.Contains("Assignee"))
{
EntityReference assigneeRef =
(EntityReference)context.InputParameters["Assignee"];
//Check if the "Assignee" is a team
if (assigneeRef.LogicalName == "team")
{
Team team;
//Retrieve the team with all properties
team = service.Retrieve(assigneeRef.LogicalName,
assigneeRef.Id, new ColumnSet(true)).ToEntity<Team>();
assigneeRef.Id, new ColumnSet(true)).ToEntity<Team>();
//Put your logic here based on the retrieved Team informations
}
}
}
}
catch (Exception e)
{
throw new InvalidPluginExecutionException("An error occured for
Assign plugin " + e.Message + e.InnerException);
Assign plugin " + e.Message + e.InnerException);
}
}