Model SDK - How to obtain the full model with details scriptically?

Hi, guys I wanted to place this again under your attention, seen the previous answer wasn't that helpful for my case. I am aware that yesterday was placed another method by Menno to obtain the model by converting the BSON mdp file to JSON, but that is not what I am looking for. Simply because I want it do it by script and automatically without any manual actions, and want to import it again as JSON to analyze the whole stuff. So I am really wondering whether someone familiar can help me with: 1) A script to get the full model with all details of all modules from the platform into one output like JSON or so where I simply can adjust and rewrite and rebuild back to a working MxApp.  What do I mean with all the stuff from the whole model (all development related elements of the MxApp): -project settings -security settings -navigation (and navigation profiles) - all modules --per module all documents like mf's, constantes, --per module security   I hope this make it more clear. In the blog there is an example of retrieving entities from certain module. I want to extent that script with for all modules, with all elements like specified here above.   EDIT 2: import { ModelSdkClient, IModel, IModelUnit, domainmodels, utils, pages } from "mendixmodelsdk"; import { MendixSdkClient, Project, OnlineWorkingCopy, loadAsPromise } from "mendixplatformsdk"; const username = 'x'; const apikey = 'xx'; const client = new MendixSdkClient(username, apikey); let projectName = 'xx'; let projectId = 'xx'; let moduleName = "MyFirstModule"; let project = new Project(client, projectId, projectName); async function serializeToJs() { const workingCopy = await project.createWorkingCopy(); const domainModelInterface = workingCopy.model().allMicroflows()[0]; try { const domainModel = await loadAsPromise(domainModelInterface); console.log(utils.serializeToJs(domainModel)); //print out the generated JavaScript console.log("success!") } catch (error) { console.log(`error: ${error}`); } } serializeToJs(); I am now getting the microflows but I do see that the some created MF's in this module are not serialized. Probably I have to get it from the right revision...   EDIT 3: Hi Simon, thnx...I know the serializetojs...but should I specify per module ...allMicroflows, allConstants, etc there not a general function to retrieve for all the modules all model elements? Enzo
2 answers

Hi Enzo,


The Model SDK has a function that allows you to take a Mendix application and the function will convert it into the relevant SDK code to rebuild your entire model.

But i'm a little unclear as to why you want to rebuild your entire model using the SDK? You can already do this without the SDK, you can export it as a project file and import this into a new project. This can be done both manually and programmatically. Also the projects API allows you to set up a new version of your project based on a template, which will spin up a new project using the given template.

If your looking to view information about the entire model, like counts of entites & pages then i would suggest this script:





I think your question is unclear and that's why you're not getting answers that are helpful to you. 

What do you want the output to look like, and why are you doing this?

There's an article here that shows you how to create a script out of a domain model. You could easily modify this to loop over every domain model (and microflow, and page) in your project to generate "create scripts" for each of them. Is that what you want to do? If not, then what, and why?