-1
Dynamics CRM 2016 ONPREMISE에 두 개의 유사한 플러그인이 하나로 병합됩니다.Dynamics CRM 2016 ONPREMISE에 두 개의 유사한 플러그인이 하나로 병합
그들은
같은 단체에 등록- ,
- 모두 업데이트 메시지에 의해 트리거, 3 개 필드 4 개 필드의 다른 검사 값의
- 하나 개의 플러그인 검사 값이야. 모두가 지정된 값과 같으면 계속 진행하십시오. 그렇지 않다면 돌아 오십시오. 4. 이전 레코드의 값을 새 레코드로 설정, 매핑 또는 계산합니다. 두 플러그인은 두 세트의 필드를 처리합니다.
- 새 레코드를 만듭니다.
내가 생각할 수있는 것은 "if else-if"구조입니다. 하지만 너무 순진 해 보입니다. 누구 조언있어?
다른 플러그인은 3 개의 다른 필드를 확인하고 설정되거나 매핑 된 다른 필드가있는 새 레코드를 만드는 비슷한 동작을 실행합니다.
덕분에,
protected void ExecuteApplication(LocalPluginContext localContext)
{
IPluginExecutionContext context = null;
IOrganizationService service = null;
ITracingService tracer = null;
context = localContext.PluginExecutionContext;
service = localContext.OrganizationService;
tracer = localContext.TracingService;
try
{
// ensure we have an application and update message
Entity application = new Entity(applicationEntityName);
if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
{
application = (Entity)context.InputParameters["Target"];
if (!application.LogicalName.ToLower().Equals(this.applicationEntityName))
{
return;
}
}
else
{
return;
}
if (context.MessageName.ToLower() != "update")
{
return;
}
// Fetch data from PreImage
Entity postImageApplication = context.PostEntityImages["PostImage"];
//check three fields are not null
if (application.GetAttributeValue<OptionSetValue>("statuscode") == null ||
postImageApplication.GetAttributeValue<EntityReference>("new_service").Name == null ||
postImageApplication.GetAttributeValue<EntityReference>("new_source").Name == null)
{
return;
}
if (
application.GetAttributeValue<OptionSetValue>("statuscode").Value == 881780003 &&
postImageApplication.GetAttributeValue<EntityReference>("new_service").Name == "CIC"
)
// process if the update meets the criteria
{
Entity newApplication = new Entity("new_application");
// set
newApplication.Attributes.Add("new_effectiveapplication", true);
newApplication.Attributes.Add("new_confirmdate", DateTime.Now);
newApplication.Attributes.Add("new_signdate", DateTime.Now);
//mapped
if (postImageApplication.Attributes.Contains("new_client"))
{
newApplication.Attributes.Add("new_client", postImageApplication["new_client"]);
}
if (postImageApplication.Attributes.Contains("new_servicecentre"))
{
newApplication.Attributes.Add("new_servicecentre", postImageApplication["new_servicecentre"]);
}
service.Create(newApplication);
}
else
{
return;
}
이 몇 가지 코드를 제시해주십시오 ... – Nicknow
어떻게 코드를 보지 않고 무엇을 제시 하는가? –