Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

How to make the Business Process flow stage should transition to match with the option set same value in crm 2015

$
0
0

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);
       


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images