Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Not able to move the business process on to the next stage. Does not set as active

Posted on by 60

Hi,

We are on premise 2016 Dynamics 365. We have an issue where we are unable to move the business process on to the next stage. It will not set as active, as below;

*This post is locked for comments

  • Suggested answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: Not able to move the business process on to the next stage. Does not set as active

    You can set them via the SDK within a console application. You'd need to retrieve the associated BPF record to your entity and then set the stageid to the coresponding stage name. Something like the snippet below :  

    using System;
    using Microsoft.Crm.Sdk.Messages;
    using Microsoft.Xrm.Sdk.Client;
    using System.ServiceModel.Description;
    using Microsoft.Xrm.Sdk.Query;
    using Microsoft.Xrm.Sdk;
    using System.Collections.Generic;
    using System.Configuration;
    using Microsoft.Xrm.Tooling.Connector;
    
    namespace BPFConsoleProject
    {
        class Program
        {
    
            static void Main(string[] args)
            {
                //Where Applies, replace with your values
    
                string userName = "username@domain.com";
                string password = "password";
                string authType = "AD";
                string url = "crmserver:port/orgName";
    
                Guid recordToFixId = Guid.Parse("record Guid on which the bpf is broken");
                string recordToFixEntityName = "name of the entity against which the bpf is configured";
    
                string businessProcessFlowName = "name of your bpf";
                Guid stageToSetId = Guid.Parse("Guid of the stage name you want to set");
    
                try
                {
                    using (CrmServiceClient crmSvc = new CrmServiceClient($"UserName={userName};Password={password};AuthType={authType};Url={url}"))
                    {
                        if (!crmSvc.IsReady)
                            throw new Exception($"Unable to connect to CRM Organization Error: {crmSvc.LastCrmError} \n {crmSvc.LastCrmException}");
    
                        // 1.   Retrieve the Active Business Process Instance set against the records
    
                        RetrieveProcessInstancesRequest retrieveProcessInstancesRequest = new RetrieveProcessInstancesRequest
                        {
                            EntityId = recordToFixId,
                            EntityLogicalName = recordToFixEntityName
                        };
    
                        RetrieveProcessInstancesResponse retrieveProcessInstancesResponse =
                            (RetrieveProcessInstancesResponse)crmSvc.Execute(retrieveProcessInstancesRequest);
    
                        Guid activeProcessInstaceId = new Guid(retrieveProcessInstancesResponse.Processes.Entities[0].Id.ToString());
    
                        Console.WriteLine("Active Process stage is: " + retrieveProcessInstancesResponse.Processes.Entities[0].Attributes["processstageid"].ToString());
    
    
                        EntityReference bpfReference =
                            (EntityReference)retrieveProcessInstancesResponse.Processes.Entities[0].Attributes["processid"];
    
                        Entity processEntity = crmSvc.Retrieve(businessProcessFlowName, activeProcessInstaceId, new ColumnSet(true));
                        processEntity["activestageid"] = new EntityReference("processstage", stageToSetId);
    
                        crmSvc.Update(processEntity);
    
                        Console.Read();
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                }
            }
    
        }
    }
    


    hope this helps

    Radu

  • Aleia Stickley Profile Picture
    Aleia Stickley 60 on at
    RE: Not able to move the business process on to the next stage. Does not set as active

    Hey,

    Firstly, thank you so much for helping me.

    They do not appear to match as would expect, how can I resolve this?

  • Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: Not able to move the business process on to the next stage. Does not set as active

    Can you check the stageid and the stagename against the record and see if there is any mismatch there ?

  • Aleia Profile Picture
    Aleia 45 on at
    RE: Not able to move the business process on to the next stage. Does not set as active

    Hi Kokulan,

    No errors or breaks when I set the stage.

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Not able to move the business process on to the next stage. Does not set as active

    Could you please check your Dev tool console (F12) to see if it logs any errors when you try to set the stage?

  • Aleia Profile Picture
    Aleia 45 on at
    RE: Not able to move the business process on to the next stage. Does not set as active

    Hi Radu,

    We have no custom JavaScript Running;

    Thank you

  • Suggested answer
    Radu Chiribelea Profile Picture
    Radu Chiribelea 6,667 on at
    RE: Not able to move the business process on to the next stage. Does not set as active

    Hello,

    Do you have any logic around the business process flow (JavaScript, Plug-ins, etc.) ? If yes - if you disable them does it work?

    I've seen this type of behavior in the past also when the stageid and the stagename on the form were not set correctly (stageid belonged to the wrong stagename of the business process flow) - this in generally was caused by custom javascript / plugins

    Hope this helps,

    Radu

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans