Invalid stage transition. Transition to stage {0} is not in the process active path.

Introduction

With latest release of Dynamics 365, Microsoft has restricted skipping BPF stages and throws above error. When we try to change BPF stage programmatically and if we skip any BPF stage, then user will get above error.

Understand the error with the help of an example

Let’s say we have below Business Process Flow on Opportunity.

sample BPF

With D365, only below transitions are allowed.

  1. Qualify to Develop
  2. Develop to Propose
  3. Propose to Close

Below transitions are not allowed.

  1. Qualify to Propose
  2. Develop to Close
  3. Qualify to Close

How my earlier code (prior to D365 release) worked and suddenly stopped working?

Before D365 release by Microsoft, the above scenarios were considered as unsupported and there were no restrictions forced by Microsoft. Hence our code used to work in these unsupported scenarios as well. With D365 release, Microsoft has restricted these unsupported scenarios and users will start receiving the error with same code.

How have I come to this conclusion?

  1. I got the error log file with error code and same error code (-2146885629) is now available in SDK (you can search in CHM file).

SDK Error Code

  1. I raised a support ticket with Microsoft and as per confirmation from MS Support, it has turned out to be by-design. I received below response from MS Support Team.

Reply from MS Support

Note: Even though Microsoft has mentioned Environment as CRM Online, as this is by-design in D365, it applies to CRM On-premise deployments as well.

Summary/Resolutions

  1. After thinking about these unsupported scenarios, it makes sense to use logical branching to skip the stages if needed and if not, then we should follow the path mentioned in BPF.
  2. The resolution to this issue can be programmatically iterate the record through all the stages or use conditional branching in BPF.

How to use Business Rules to determine Form Type in Dynamics CRM

Introduction

One of the frequent requirement we receive is doing basic form customizations based on Form Type. E.g. Show few fields while creating record and hide those fields once record is saved.

First option which comes in developer’s mind

As we cannot check entity’s form type using Business Rules, we must use JavaScript to achieve this requirement. Hence, usually developer will write a JavaScript method and register an event on Form Load.

This will be time consuming task as compared to the solution which I have explained below. Also, it will need technical person to achieve this requirement, because it involves coding.

An option that usually skips from developer’s mind

As we know, Created On field is populated only when record is created. Also, CRM does not allow to set Created On field to the user, we can take help of this field to determine whether user is on Create form or has opened existing record.

Below screenshot shows how Business Rule can be configured to unlock the Account on Create form and lock it for existing record.

business rule

Simple solution, but we usually miss it.

How alternate key is useful while importing data into CRM?

Introduction

In this blog, I have explained how an alternate key column can be used to import the data into CRM using OOB import/export facility.

We get frequent requirements to perform initial data load for customers and contacts. In almost all cases, we are asked to link the Contacts to the customers.

This can be achieved easily using Alternate Key in CRM.

In this blog, I have assumed that we have Account Number field as an alternate key on Account entity and Contact Number (custom field) as an alternate key on Contact entity.

How to achieve this?

Case 1 (initial load): We have 2 separate Excel/CSV files as per below screenshots.

Customers

1

Contacts

2

  1. We will first import the data of Account (as it is straightforward I have not explained about it in this blog).
  2. Then we import the contacts. This is also straightforward except one below check in field mapping.
    1. In field mapping we have to select the Account Number as a matching field for Company Lookup field.

3

Case 2 (Update existing data): Now we have contacts with accounts selected, on Accounts we need to select primary contact.

Let’s say we have below CRM view and we click on Export to Excel and put the contact numbers appropriately in Primary Contact column in Excel.

4

If you note in below screenshot, I have renamed Primary Contact field to Contact Number which contains Contact Numbers.

5

NOTE: IF WE DON’T RENAME THE COLUMN, IMPORT WIZARD WILL NOT SHOW FIELD MAPPING WINDOW AND WILL DIRECTLY START IMPORTING THE DATA AND EVENTUALLY WILL RESULT IN FAILURE.

  1. Now we save the exported Excel with contact numbers and start data import with the same file. It will again give similar field mapping dialog where we have to select Contact Number as a matching field for Primary Contact field.

6

  1. After completing import wizard steps, you will see the result as below:

7