Search code examples
javascriptmirth

How do I get the Mirth Connect Environment Name in a script?


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?


Solution

  • 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