Can constants be changed at runtime?

0
I'm reopening this old question, just to see if something changed (I think this was mentioned in one of the recent Mendix posts). Can constants or simple properties of an application be changed at runtime?
asked
2 answers
1

Not at runtime, only when starting the application.

Constant definitions (name and default value) are always configured in the modeler. However, you can (and should!) provide different values depending on which environment you're running.

In the standard cloud you can configure them from the portal. Assuming you're using m2ee-tools, you can configure them under Linux using m2ee.yaml

For Windows, there's a service console that allows you to edit these values, under the "application constants" tab.

answered
0

At least in Mendix 9 (maybe earlier) you can call the semi-documented method to update the constants:

		// BEGIN USER CODE
        final Configuration conf = Core.getConfiguration();
        final Map<String, Object> map = new HashMap<>();
        final Map<String, Object> map2 = new HashMap<>();
        map.put("MicroflowConstants", map2);
        map2.put(name, value);
        conf.updateConfiguration(map, true);
        if (!Objects.equal(value, conf.getConstantValue(name))) {
            throw new CoreException("Constant value was not updated");
        }
        return null;

 

answered