Can not load Domain model using Mendix SDK.

I want to use Mendix SDK to create entities  and loading it inside Mendix app, i think the SDK not able to see and catch domain model , i got TypeError of type "undefined load function".  I follow the mendix SDK Doc, unfortunately, not well updated with the latest version of Mendix Model/SDK 4.6.0/4.0.0.  The Error  Successfully opened new online working copy xxxxx-xxxxx-xxxxx-xxxx-xxx- for project xxxxx- xxxxx-xxxx-xxxx-xxxxx : ProjectName  error: TypeError: Cannot read property 'load' of undefined Test Code  const dm = workingCopy.model().allDomainModels() .filter(dm => dm.structureTypeName === 'MyFirstModule')[0]; return loadAsPromise(dm).then((q) => { // console.log(dm.isLoaded); // console.log(utils.serializeToJs(q)); //print out the generated JavaScript // return workingCopy; }); // console.log(dm); Thanks in advanced     
2 answers

The problem is in the following line:

.filter(dm => dm.structureTypeName === 'MyFirstModule')[0];

The property 'structureTypeName' contains a textual representation of the type of the object. In this case, it will always be "DomainModels$DomainModel", as you are filtering domain models. As the result of filtering will be an empty array, taking the first element of that will yield 'undefined', which causes the error you get later on.

It looks like you want to get the domain model for the module called 'MyFirstModule'. If you change the line to the following, it should work:

.filter(dm => === 'MyFirstModule')[0]



Solved .

Thanks Benny;