Offline default values of attributes

Hi all, I'm currently working on an offline inspection application. However, I have some troubles with creating new objects offline. I would like to have default values for several attributes (default values should be CurrentDateTime, Enumerations and boolean values). But these are not generated if I create an object offline. Anybody knows how to do this, or if this is yet possible in the offline profile?  Thanks in advance! Ward
3 answers

Hi Ward,

This functionality for offline profiles is yet not available out of the box in Mendix.

You can accomplish this right now with some custom JavaScript. Here's how you would do it:

  • You'd need to first enable the HTML Snippet (with context) widget so you can use it in offline mode. Or perhaps you could use one of the other JavaScript widgets in the app store. You'd need to modify the second line of the XML file in the widget and add the property offlineCapable="true"
  • Drop an HTML Snippet on the page where you've created the new object. In the HTML Snippet, set it to JavaScript mode and then you can use functions calls like this to set attributes on your context entity.





I ran into the same problem as you and I solved it by creating a custom widget where I could select in the modeler which attribute I want to pass and what the default value I want it to be.


Thank you both for your answers!

For a quick fix we now used the Mendix Switch widget (which is always default on false)  and made it invisible on the page. 

Will definitely try your suggestion :) !