One of the exposed Properties within an Expression is Process.EnvironmentName, which, when evaluated at execution time, returns the name of the Environment for a particular Process Instance. You can use Expressions in multiple places in BPM, such as Data Item Assignments within any Activity or Calculation Data Items or configuration values within Activities.
Let's return to our example of accessing custom tables within the BPM Runtime Databases for Test and Production. As in Method 1, create an ODBC Resource with the Data Item: RuntimeDatabaseConnectionString for the connection string. Then, within an Activity, use the Data Item Assignments to assign the value to the RuntimeDatabaseConnectionString, by selecting the Expression Editor

Within the Expression Editor, we use an If statement with the Process.EnvironmentName property, allowing us to assign the appropriate Value for the Data Item to contain the connection string based upon the environment

At execution time, the Data Item within the Resource evaluates to the correct database, ensuring that we access the Test database when running in Test and the Production database when running in Production.
Additional Notes
-
When calculating the value of your Data Item, Bluespring recommends using Data Item Assignments rather than a Calculated Data Item
-
The Process.EnvironmentName property can not be detected within your Initiator's Data Item Assignments. So, you will need to populate any environment-specific Data Items in the second step of your Processes
-
Bluespring recommends testing population of environment-specific Data Items and their use in each case or all environments involved, to make sure everything processes as you desire
-
In an implementation with more than 2 environments, use the IfChain function within your Expression. For example:
IfChain(Process.EnvironmentName="RuntimeDevelopment", "Provider=SQLOLEDB.1;Persist Security Info=True;Data Source=[Server Name]\[Instance Name];Initial Catalog=[Database Name];Connection Timeout=180;User ID=[SQL User Name];Password=[Password];Enlist=False", Process.EnvironmentName="RuntimeTest", "Provider=SQLOLEDB.1;Persist Security Info=True;Data Source=[Server Name]\[Instance Name];Initial Catalog=[Database Name];Connection Timeout=180;User ID=[SQL User Name];Password=[Password];Enlist=False", Process.EnvironmentName="RuntimeProduction", "Provider=SQLOLEDB.1;Persist Security Info=True;Data Source=[Server Name]\[Instance Name];Initial Catalog=[Database Name];Connection Timeout=180;User ID=[SQL User Name];Password=[Password];Enlist=False", "Error - Unexpected Environment Name: " & Process.EnvironmentName)