2

I'm running Mirth Connect Server 3.8.1. The settings page has two fields, Environment Name and Server Name:

enter image description here

I've been able to get the Server Name in a script the following way:

var configurationController = Packages.com.mirth.connect.server.controllers.ConfigurationController.getInstance();
var serverName = configurationController.getServerName();

But I have not been able to get the Environment Name. The obvious guess that didn't work and only resulted in an error was:

var environmentName = configurationController.getEnvironmentName();

How to get this field?

  • Future reference for anyone arriving here: the full list of methods available on ConfigurationController can be found [here](https://github.com/nextgenhealthcare/connect/blob/86fe07b42d5513ca36c4e0521de23a98f59c8edd/server/src/com/mirth/connect/server/controllers/ConfigurationController.java#L41). – Michael Kopinsky Jan 04 '21 at 20:57

2 Answers2

2

This should work.

var serverSettings = configurationController.getServerSettings();
var environmentName = serverSettings.getEnvironmentName();

The serverSettings object also has the server name available among other settings. See source here: https://github.com/nextgenhealthcare/connect/blob/3.8.x/server/src/com/mirth/connect/model/ServerSettings.java

agermano
  • 1,679
  • 6
  • 16
1

For folks finding this thread, here's a function that returns the Mirth environment name.

function getEnvironmentName () {
var configurationController = Packages.com.mirth.connect.server.controllers.ConfigurationController.getInstance();
var serverSettings = configurationController.getServerSettings();
var environmentName = serverSettings.getEnvironmentName();
return environmentName;

}

SH_ia
  • 29
  • 6
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 30 '22 at 03:53