Constants into variables - Mendix Forum

Constants into variables

0

Hi all, 

I have created a constant in my project that is used several times in a project and that has a default value. 

Now I have found ut that for this use case it would be benefitial to change the value and make it variable. Is there a possibility to easily change the constant into a variable without editig the whole setup of the project. Does anyone have an idea?

 

Thanks in advance.

asked
2 answers
2

AFAIK this type of conversion is not possible as you could have different values locally, configured per database as well as per cloud node

answered
1

You could create a Singleton object as entity with a CreateOrRetrieve pattern.

That means you create a senseful entity where you want to store your value, that you have currently as constant. Then you create a microflow which retrieves the first object from the entity. If the object is empty, you create a new object (maybe you can add there your default value) and then you return this object. The other direction of the split in the microflow means, your object is already existing. In that case, you only retrieve the object. This makes sure you have only one object of this entity. Everytime when you need this value, you can use the creator retrieve microflow to get the current value. You also have the possibility, to build a configuration page to maintain the value of the singleton.

 

answered