App Architecture - How to access data between modules

0
I am going through the introduction course before starting my first app.  It appears it is logical to seperate the app into logical modules to organize the development.   In my case I want a Projects module as we are a design firm.  I want one module for project management.  I want another for CRM.  BUt there are links between the two.  Can I share, access, and edit data between modules?  How would I go about doing that?
asked
2 answers
2

Ivan,

The entities in different domain models can be associated as is the case in the a single domain model. Open the properties of an entity and swith to the associations tab. Then press new and you're able to select entities that are and are not contained in the current domain model.

The same is true for data in different modules, this can be accessed across modules kieeping in mnd the security roles you setup in the different modules and on the entities in the form of access rules.

answered
0

Meh, I'm passionately starting to hate this forum.... Anyhow my comment was html escaped. Tried to copy it to clipboard, it didn't...

So here we go again:

If you want to know what the database structure looks like in mendix you can open View > Console > Advanced (dropdown) > Start built-in database viewer. Here you see the tables generated by your domain model and you can navigate and manipulate it on your local development machine using SQL commands. (note that entity tables and the association tables are seperated, deleting entities out of the database using the database viewer can definitely damage your data integrity if not handled carefully)

Other than that you are indeed capable of creating links between modules through associations. But also through generalizations you can achieve connections. I recommend using associations though for most use-cases.

Also just to give you a small tip before starting to built your application in a way your models will become bloated and unmanagable, try to find commonly shared entities. A management application could easily consist out of many many other modules that if you make them smaller might even be re-usable for different applications in a later stage of your development career in Mendix. Try to extract simple functionalities.

I can highly recommend if you're just getting started with creating domain models that you read the book Domain Driven Design by Eric Evans, perhaps it feels a bit dated the book and it is a struggle to get through it all in one sit. But it will definitely give you some new insights.

And this isn't something that is immediately clear either when you're new to Mendix and using JAVA actions from the Appstore (For example the rest module/CommunityCommons), they often require you to give parameters as string value. Like microflows or entities or an xpath that can be retrieved.

Here is how you do that XPATH as a string value (note that in the regular XPath retrieve action the // is not required but as a JAVA parameter string it is:
'//ModuleName.EntityName[attribute = value //Or your XPATH]'

Same goes for giving an entity or microflow as a parameter to the JAVA actions

'ModuleName.EntityName'
'ModuleName.MicroflowName'

answered