Hi Fredrik,
Whenever I need a global variable I use the singleton pattern. For mendix that looks something like this.
1) Create a persistant entity e.g. "MyEntity"
2) Create a microflow "DS_MyEntity_GetOrCreate" that attempts to retrieve the enttiy from DB or creates a new one if it is not found in the DB (a good practice is to add the name singleton in the domain model and an annotation that explains how to get an instace)
3) Always use the DS microflow whenever you need access to the global variable.
Hope this helps,
-Andrej
PS: If you want a variable per User or per Session then you should associate "MyEntity" to either the User or Account or Session objects. Update the retrieve in the DS microflow retrieve action to also check this association. Remember you have access to the user and session in each microflow via the variables currentUser and currentSession
Hi Fredrik,
Other than a Constant you mean?
You could create a 'AdminSettings' (or 'ApplicationVariables' or whatever) entity which is available to the Admin (and of which only 1 object exists), with variables that can be set and changed: like an 'updateRequired' boolean. This can then be set runtime, and take effect immidiately. When checking as a user you can look at this entity.
Is this what you mean, or did I misinterpret your requirement?
EDIT: looks like I was 19 seconds too slow, good thing is that Andrej suggests a similar solution :)