Autochange business process flow by name
If you are using code with hardcoded process ID values on the sames web site this is not a problem. The problem arises as soon as you will try to deploy your customizations on another Dynamics 365 Common Data Service or CRM instance. In this case business process will be imported with new IDs and you need to manually update their values.
In case of multiple instances or continuous integration this can be annoying.
To avoid a problem, businees process flow's (BPF) names can be used instead.
In my example I assume that there are 2 activated processes with names <Process 1 name> and <Process 2 name>.
A main form entity contains an attribute RequestType. Depending on its value processes should be switched.
Here is an example of a TypeScript class that performs this action
Entry point is a function processOnLoad, it should be added to a form's onLoad event handler.
In a function changeProcessByRequestType will be searched in active processes for IDs of a processes with given names <Process 1 name> and <Process 2 name>.
If they are found their IDs will be transfered to a function switchProcess. In this function will be checked whether process corresponds to a value of a RequestType attribute.
In a code there are hardcoded values of a process names, they will not be changed while transferring to another environment. Thus you can avoid problem with deployment.