MxMetaObject
mendix.lib.MxMetaObject
is an Object that provides access to meta data of an Entity in the current session associated with an application specific Domain Model.
mendix.lib.MxMetaObject
should never be instantiated manually.
h3. .getAttributes()
This method will return an Array containing the names of all the attributes in this MxObject.
Parameters
None
Returns
Array
Example
var attrs = mxobject.getAttributes(); // ["Name", "Age"];
h3. .getAttributesWithoutReferences()
h3. .getEntity()
This method will return a String with this object’s Entity name.
Parameters
None
Returns
String
Example
mxobject.getEntity(); // "System.User"
h3. .getEnumCaption(attr, key)
This method will return the (translated) value of key (if any) of the Enumeration of attribute attr .
Parameters
attr
Stringkey
String
Returns
Array
Example
mxobject.getEnumCaption("Color", "red"); // "Rouge"
h3. .getOptions(attr)
This method will return the Enumeration keys of this attribute (if any) in an Array.
Parameters
attr
String
Returns
Array
Example
mxobject.getOptions("Color"); // ["red", "green", "blue"]
.getSelectorEntity(attr)
This method is used to get the Entity of a reference attribute.
Parameters
Name | Type | Description |
---|---|---|
attr | String | The reference attribute whose Entity to return. |
Returns
Type | Description |
---|---|
String | A String with the Entity name |
Example
mxobj.getSelectorEntity('Order_OrderLine'); // "CRM.OrderLine"
h3. .getSubEntities()
This method will return an Array with the names of the Entities that inherit from this Entity (if any).
Parameters
None
Returns
Array
Example
mxobject.getSubEntities(); // ["MyModule.EntityA", "MyModule.EntityB"]
h3. .getSuperEntities()
This method will return an Array with the inheritance chain of this Entity (if any).
Parameters
None
Returns
Array
Example
mxobject.getSuperEntities(); // ["MyModule.EntityC", "MyModule.EntityD", "System.User"]
h3. .has(attr)
This method is called to determine if this object has the requested attribute and returns true if it does and false if it does not.
Parameters
attribute
[ String ]
Returns
Boolean
Example
if (mxobject.has("Name")) {
alert("This mxobject does have the attribute 'Name'.");
} else {
alert("This mxobject does not have the attribute 'Name'.");
}
h3. .hasSubEntities()
This method is called to determine if other entities inherit from this entity type and returns true if it does and false if it doesn’t.
Parameters
classname
[ String ]
Returns
Boolean
Example
if (mxobject.hasSubEntities()) {
alert("Other Entities inherit from this Entity");
} else {
alert("Other Entities do not inherit from this Entity");
}
h3. .hasSuperEntities()
This method is called to determine if the entity type of this object inherits from other entities and returns true if it does and false if it doesn’t.
Parameters
classname
[ String ]
Returns
Boolean
Example
if (mxobject.hasSuperEntities()) {
alert("This object inherits from another Entity");
} else {
alert("This object does not inherit from another Entity");
}
h3. .inheritsFrom(classname)
This method is called to determine if the entity type of this object inherits from classname and returns true if it does and false if it doesn’t.
Parameters
classname
[ String ]
Returns
Boolean
Example
if (mxobject.inheritsFrom("System.User")) {
alert("This object inherits from System.User");
} else {
alert("This object does not inherit from System.User");
}
h3. .isA(classname)
This method is called to determine if this object is an instance of classname and returns true if it does and false if it doesn’t.
Parameters
classname
[ String ]
Returns
Boolean
Example
if (mxobject.isA("System.User")) {
alert("This object is a System.User");
} else {
alert("This object is not a System.User");
}
h3. .isBoolean(attr)
This method is a convenience method and is called to determine if attribute attr of this object is of type Boolean and returns true if it does and false if it doesn’t.
Parameters
attribute
[ String ]
Returns
Boolean
Example
if (mxobject.isBoolean("Amount")) {
alert("Attribute " + attr + " is a Boolean");
} else {
alert("Attribute " + attr + " is not a Boolean");
}
h3. .isCurrency(attr)
This method is a convenience method and is called to determine if attribute attr of this object is of type Currency and returns true if it does and false if it doesn’t.
Parameters
attribute
[ String ]
Returns
Boolean
Example
if (mxobject.isCurrency("Amount")) {
alert("Attribute " + attr + " is a Currency");
} else {
alert("Attribute " + attr + " is not a Currency");
}
h3. .isDate(attr)
This method is a convenience method and is called to determine if attribute attr of this object is of type Date and returns true if it does and false if it doesn’t.
Parameters
attribute
[ String ]
Returns
Boolean
Example
if (mxobject.isDate("DoB")) {
alert("Attribute " + attr + " is a Date");
} else {
alert("Attribute " + attr + " is not a Date");
}
h3. .isEnum(attr)
This method is a convenience method and is called to determine if attribute attr of this object is of type Enumeration and returns true if it does and false if it doesn’t.
Parameters
attribute
[ String ]
Returns
Boolean
Example
if (mxobject.isEnum("Selections")) {
alert("Attribute " + attr + " is an Enumeration");
} else {
alert("Attribute " + attr + " is not an Enumeration");
}
h3. .isLocalizedDate(attr)
This method is a convenience method and is called to determine if attribute attr of this object is of type Localized Date and returns true if it does and false if it doesn’t.
Parameters
attribute
[ String ]
Returns
Boolean
Example
if (mxobject.isLocalizedDate("Selections")) {
alert("Attribute " + attr + " is an Localized Date");
} else {
alert("Attribute " + attr + " is not an Localized Date");
}
h3. .isNumber(attr)
This method is a convenience method and is called to determine if attribute attr of this object is of type Number and returns true if it does and false if it doesn’t.
Parameters
attribute
[ String ]
Returns
Boolean
Example
if (mxobject.isNumber("Count")) {
alert("Attribute " + attr + " is a Number");
} else {
alert("Attribute " + attr + " is not a Number");
}
h3. .isObjectReference(attr)
h3. .isObjectReferenceSet(attr)
h3. .isPassword(attr)
This method is a convenience method and is called to determine if attribute attr of this object is of type Password and returns true if it does and false if it doesn’t.
Parameters
attribute
[ String ]
Returns
Boolean
Example
if (mxobject.isPassword("Password")) {
alert("Attribute " + attr + " is a Password");
} else {
alert("Attribute " + attr + " is not a Password");
}