Hi all,
I wrote a plugin to match the option set value with the Business Process flow stage . The problem is that
if we are changing the option set value the stage is changed with the flag notification as active
but the previous stage also notify as selected. I need to remove this previous stage notification.
This is the code i used
var status = application.asqa_RegApplicationStatus;
if (status == null) return;
var processId = application.processid;
if (Context.PostEntityImages.Contains("PostImage"))
{
var postImage = Context.PostEntityImages["PostImage"]
.ToEntity<asqa_RegistrationApplication>();
processId = processId ?? postImage.processid;
}
IList<ProcessStage> processStages;
using (var c = new XrmServiceContext(OrganizationService))
{
processStages = c.ProcessStageSet.Where(x => x.ProcessId.Id == processId).ToList();
}
var regApp = new asqa_RegistrationApplication { Id = application.Id, processid = processId };
switch (status.Value)
{
case (int)EnRegApplicationStatus.Reviewing:
{
var processStage = processStages.FirstOrDefault(p => p.StageName == CRMConstants.BusinessProcessFlow.VetMaterialChangeRegistration.Reviewing);
if (processStage != null)
{
regApp.stageid = processStage.ProcessStageId;
}
break;
}
case (int)EnRegApplicationStatus.Returned:
{
var processStage = processStages.FirstOrDefault(p => p.StageName == CRMConstants.BusinessProcessFlow.VetMaterialChangeRegistration.Returned);
if (processStage != null)
{
regApp.stageid = processStage.ProcessStageId;
}
break;
}
}
UpdateEntityRecord(regApp);









