How can I call model sdk script form mendix modeler only ?

0
We want to import a excel file values eg: {attributeName,EntityNames,Type,ModuleName) in an entity and want to create all those entities,modules and attributes automatically in the modeler. What should be the approach for this problem?  How can we get and use those excel values in the script to create entities and attributes in modeler ?
asked
2 answers
0

That requires some scripting, see this post

As alternative you can create XSD from your excel and create a domein model from the schema.

 

You could do that from Mendix

  1. Create entity with name _entity and your attributes
  2. Use ExcelImport from appstore
  3. Import your data
  4. Create a microflow that run your data in the correct order
  5. Create an xsd like below
  6. Store that string in a filedocument (Community commons java-action)
  7. Download the file document (entities.xsd)
  8. Import the filedocument as schema
  9. Goto domain model 'Import web service/XML file

 

XSD structure

<?xml version="1.0" encoding="utf-8"?>
<xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="Something" nillable="true" type="Something" />
  <xs:complexType name="Something">
    <xs:sequence>
      <xs:element minOccurs="1" maxOccurs="1" name="ID" type="xs:int" />
      <xs:element minOccurs="0" maxOccurs="1" name="First_Name" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="Last_Name" type="xs:string" />
      <xs:element minOccurs="0" maxOccurs="1" name="Phone_number" type="xs:string" />
    </xs:sequence>
  </xs:complexType>
</xs:schema>

 

But is it worth the effort?  That is up to you.

 

answered
0

0. Create a web service which expose the required data in your Mendix app. Create also a microflow which is started when the button is clicked and it makes a request to the nodejs server in step 1 , for example GET.

1.Create a nodejs simple server which execute command on command line "node yourfilename.js" when a request arrive (You will hardcode the command "node yourfilename.js"  inside the code for the server so it do only this action when receive a request for security reasons). Place this file inside your mendix sdk folder so the path "yourfilename.js" works, otherwise you must specify the full path.

2. inside your mendix sdk file create a request to your Mendix app service that you've created in step 0 using some library like "request".

3. Start the server from the command line like "node myserver.js"

Go to your app, click your button  and that's it, your file will be executed and create/update app.

answered