Hi Guys,
I have used for below code with Assign Message. but I got Business Error alert once get a costume message. Please verify .
if (context.InputParameters.Contains("Target") &&
context.InputParameters["Target"] is EntityReference)
{
EntityReference targetEntity =
(EntityReference)context.InputParameters["Target"];
if (context.InputParameters.Contains("Assignee"))
{
EntityReference assigneeRef =
(EntityReference)context.InputParameters["Assignee"];
Guid modifiedById = context.InitiatingUserId;
Entity savedEntity = service.Retrieve("account", targetEntity.Id, new Microsoft.Xrm.Sdk.Query.ColumnSet(new string[] { "modifiedon", "modifiedby", "statuscode", "ownerid" }));
EntityReference Owner = savedEntity.GetAttributeValue<EntityReference>("ownerid");
if (Owner.Name != "admin")
{
throw new InvalidPluginExecutionException("This record already assigned");
}
else
{
return;
}
}
}