How to create an entity using javascript

I want to create a simple entity using javascript. The entity must have a name and a single string attribute. Please suggest the easiest way to do it. I have no prior experience in Mendix.
2 answers

I am assuming that by entity you actually mean object and what you want to do is create a new object to store some data? If so this is how you can do it using the client API:

    entity: "MyFirstModule.Cat",
    callback: function(obj) {
        console.log("Object created on server");
    error: function(e) {
        console.error("Could not commit object:", e);


If you truly want to create a new entity with a new attribute, this can also be done using the Model SDK:


workingCopy => {
	const dm = pickDomainModel(workingCopy);
	const domainModel = dm.asLoaded();

	const customer = domainmodels.Entity.createIn(domainModel); = `Customer`;
	customer.location = { x: 100, y: 100 };

	const invoice = domainmodels.Entity.createIn(domainModel); = `Invoice`;
	invoice.location = { x: 400, y: 100 };

	return workingCopy;


function passStringToMicroflow(stringValue) {
    //You must create an entity in some module's domain model. In this example the module is: 
    // "ModuleNameWhereEntityIsCreated"
    // and the entity name is "YourEntityName".
    //This entity must have a string as a property. In this example is "MyStringPropertyName".
    //In Mendix it is  possible to pass only objects from JS to microflows .
    //So here is the code:{
        entity: "ModuleNameWhereEntityIsCreated.YourEntityName",
        callback: function (obj) {
            obj.set('MyStringPropertyName', stringValue);
                params: {
                    applyto: "selection",
                    actionname: "SomeModuleNameWhereMicroflowIs.TheNameOftheMicroflow",
                    guids: [obj.getGuid()],