Skip to main content
Newcomer
March 28, 2023
Solved

How to identify which environment a BR is running in?

  • March 28, 2023
  • 4 replies
  • 0 views

I have some business rules that need to identify which environment the BR is running in. This is because they does different things in each environment. In one BR i want the process to run in Prod but not QA or Dev, in another i want to copy extract files to an external shared folder which is different for each environment.  I was thinking of using a dashboard parameter but if after a Prod to Dev/QA refresh i forget to change the value of the parameter, the BR will copy the files to the Prod external folder and i don't want that to happen. this is why i am trying to find a way to identify the environment without relying on the value in a parameter.  Any thoughts?

Have a great day!

Bill

Best answer by hiren

You could retrieve the connection URL using,

si.WebServerUrlUsedByClient

& differentiate the Environment by identifying specific keywords (Dev/Stage/Prod) in it.


4 replies

Newcomer
March 28, 2023

Please see if the substitution variable |AppName| helps. This is a general substitution variable cand provides the application name. It can be used in Business rules.

Newcomer
March 28, 2023

Unfortunately we use the same application name for all our environments.  We are currently On-Prem.  When we refresh from Prod to Dev and QA we do not rename the Dev/QA applications.  if we did, that would work great. Any other thoughts?

hirenAnswer
Newcomer
March 28, 2023

You could retrieve the connection URL using,

si.WebServerUrlUsedByClient

& differentiate the Environment by identifying specific keywords (Dev/Stage/Prod) in it.


Newcomer
March 28, 2023

hiren, Thank you, that is exactly what I needed. 

Newcomer
May 15, 2024

si.WebServerUrlUsedByClient gave an empty string when I tried using it in v8.2.1. As an alternative solution, I ended up creating a system level dashboard parameter to store this info in the framework database. Should work for us as we only copy applications between environments.

Contributor
May 19, 2024

Try this.

Dim harvestFolder As String = BRAPi.Utilities.GetFileShareFolder(si, FileShareFolderTypes.BatchHarvest, Nothing)
Dim serverName = harvestFolder.Split("\")(2)

Just grabbed it out of some code lying around but believe it works.

Newcomer
November 18, 2024

I need to use the environment name defined in the "Environment Name" variable in System tab, I need to use it in business rule. I need to use "FPCC_NonProd" in the business rule.

 

ST1_0-1731898241085.png

Can you please suggest how can I use ?

Newcomer
November 18, 2024

At least you can find it it in the ServerConfig table in Framework database.

				Dim sql As String = "
					SELECT TOP 1 
						TextValue 
					FROM ServerConfig
					WHERE ItemName2 = 'EnvironmentName'
				"
				
				Using dbConnFW As DBConnInfo = BRApi.Database.CreateFrameworkDbConnInfo(si)
				    Using dt As DataTable = BRAPi.Database.ExecuteSql(dbConnFW, sql, True)
				        If Not dt Is Nothing Then
				            BRApi.ErrorLog.LogMessage(si, dt.Rows(0).Item("TextValue"))
				        End If
				    End Using
				End Using

Not sure if there's a smarter way.