나는 ms crm 2016에 대해 다음과 같은 중복을 감지하는 플러그인을 작성했습니다."ms crm duplication plugin"을 예외없이 메시지없이 완료하는 방법은 무엇입니까?
public void Execute(IServiceProvider serviceProvider)
{
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
var service = (IOrganizationService)serviceFactory.CreateOrganizationService(context.UserId);
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
var entity = (Entity) context.InputParameters["Target"];
var name = entity.GetAttributeValue<string>("name");
var opportunityCompany = new QueryExpression
{
EntityName = entity.LogicalName,
ColumnSet = new ColumnSet("name")
};
opportunityCompany.Criteria.AddCondition("name", ConditionOperator.Equal, name);
var retrieveAccount = service.RetrieveMultiple(opportunityCompany);
//If the retrieved Company Count Greater Than 1 , following Error Message Throw
if (retrieveAccount.Entities.Count > 1)
{
throw new InvalidPluginExecutionException("Following Record with Same Name is Exists");
}
}
}
잘 작동하지만 중복 된 경우 예외없이 그리고 페이지에 메시지없이 레코드 만들기를 끝내기를 원합니다. 플러그인에서 어떻게 할 수 있습니까? 어떤 사람들은 CodeActivity에서 이것을 구현할 수 있다고 말합니다. 어떻게 ms crm 플러그인에서 CodeActivity를 구현할 수 있습니까?
아니면 "사용자"가 알지 못하게 플러그인을 중지하고 싶습니다. 얼마나 잘 했니?