Constructor
new mendix/lib/MxMetaObject()
Constructs a new MxMetaObject
.
Methods
getAttributes() → {Array.<string>}
Returns the names of all attributes.
Returns:
the names of the attributes
- Type
- Array.<string>
Example
var attrs = mxmetaobject.getAttributes(); // [ "Name", "Age" ];
getAttributesWithoutReferences() → {Array.<string>}
Returns the names of the non-reference attributes.
Returns:
the names of the attributes
- Type
- Array.<string>
getEntity() → {string}
Returns the entity name.
Returns:
name of the entity
- Type
- string
getEnumCaption(attr, value) → {string}
Returns the caption of an enumeration value.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute |
value |
string | enumeration value |
Returns:
the caption of the enumeration value.
- Type
- string
Example
mxmetaobject.getEnumCaption("Color", "red"); // "Rouge"
getEnumKVPairs(enumeration) → {Object.<string, string>}
Returns values and their captions of an enumeration attribute.
Parameters:
Name | Type | Description |
---|---|---|
enumeration |
string | attribute to get the pairs for |
- Deprecated:
- since version 8.14, use getEnumMap instead.
Returns:
map from values to captions of the enumeration attribute
- Type
- Object.<string, string>
Example
mxmetaobject.getEnumKVPairs("Color"); // { red: "Red",
// green: "Green",
// blue: "Blue" }
getEnumMap(enumeration) → {Array.<{key: string, caption: string}>}
Returns the enumeration values and captions of an enumeration in the correct order.
Parameters:
Name | Type | Description |
---|---|---|
enumeration |
string | attribute to get the values and captions for |
Returns:
values and caption of the enumeration
- Type
- Array.<{key: string, caption: string}>
Example
mxmetaobject.getEnumMap("Color"); // [ { key : "red", caption : "Red" },
// { key : "green", caption : "Green" },
// { key : "blue", caption : "Blue" } ]
getOptions(enumeration) → {Array.<string>}
Returns the possible values for an enumeration attribute.
Parameters:
Name | Type | Description |
---|---|---|
enumeration |
string | attribute to get the values for |
Returns:
possible values of the attribute
- Type
- Array.<string>
Example
mxmetaobject.getOptions("Color"); // [ "red", "green", "blue" ]
getReferenceAttributes() → {Array.<string>}
Returns the names of the reference attributes.
Returns:
the names of the attributes
- Type
- Array.<string>
Example
var refs = mxmetaobject.getReferenceAttributes(); // [ "Mod.Person_Parent",
// "Mod.Person_Company" ]
getSelectorEntity(attr) → {string}
Returns the referred entity of a reference attribute.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | reference attribute |
Returns:
entity name
- Type
- string
Example
mxobj.getSelectorEntity("CRM.Order_OrderLine"); // "CRM.OrderLine"
getSubEntities() → {Array.<string>}
Returns the entities that inherit form this entity.
Returns:
the inheriting entities
- Type
- Array.<string>
Example
mxmetaobject.getSubEntities(); // [ "MyModule.EntityA", "MyModule.EntityB" ]
getSuperEntities() → {boolean}
Returns the inheritance chain of this entity.
Returns:
the names of the entities in the inheritance chain.
- Type
- boolean
Example
mxmetaobject.getSuperEntities(); // [ "MyModule.EntityC",
// "MyModule.EntityD",
// "System.User" ]
has(attribute) → {boolean}
Checks whether this entity has a specific attribute.
Parameters:
Name | Type | Description |
---|---|---|
attribute |
string | to check |
Returns:
true
if the MxMetaObject
has the attribute, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.has("Name")) {
console.log("has Name");
} else {
console.log("does not have Name");
}
hasSubEntities() → {boolean}
Checks whether other entities inherit from this entity.
Returns:
true
if other entities inherit from this entity, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.hasSubEntities()) {
console.log("is inherited from");
} else {
console.log("is not inherited from");
}
hasSuperEntities() → {boolean}
Checks whether this entity inherits from another entity.
Returns:
true
if the entity inherits from another entity, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.hasSuperEntities()) {
console.log("inherits from another entity");
} else {
console.log("does not inherit from another entity");
}
inheritsFrom(ancestor)
Checks whether this entity inherits from another.
Parameters:
Name | Type | Description |
---|---|---|
ancestor |
string | the entity to check for ancestry |
Returns:
true
if this entity inherits form ancestor
, false
otherwise
Example
if (mxmetaobject.inheritsFrom("System.User")) {
console.log("inherits from System.User");
} else {
console.log("does not inherit from System.User");
}
isA(entity)
Checks whether this entity is an instance of or inherits from another entity.
Parameters:
Name | Type | Description |
---|---|---|
entity |
string | entity to check for ancestry |
Returns:
true
if the object is an instance of entity
, false
otherwise
Example
if (mxmetaobject.isA("System.User")) {
console.log("a System.User");
} else {
console.log("not a System.User");
}
isBidirectionalReference(attr) → {boolean}
Checks whether a reference attribute is owned by both sides
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is a reference which is owned by both sides, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isBidirectionalReference("Children" {
console.log("bidirectional reference");
} else {
console.log("not a bidirectional reference");
}
isBoolean(attr) → {boolean}
Checks whether an attribute is of type Boolean.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is of Boolean type, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isBoolean("Checked")) {
console.log("Boolean");
} else {
console.log("not a Boolean");
}
isDate(attr) → {boolean}
Checks whether an attribute is of type Date.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is of Date type, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isDate("DoB")) {
console.log("Date");
} else {
console.log("not a Date");
}
isEnum(attr) → {boolean}
Checks whether an attribute is of type Enumeration.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is of Enumeration type, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isEnum("Colors")) {
console.log("Enumeration");
} else {
console.log("not an Enumeration");
}
isLocalizedDate(attr) → {boolean}
Checks whether an attribute is of type Date and is localized.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is of Date type and is localized, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isLocalizedDate("DoB")) {
console.log("localized Date");
} else {
console.log("not a localized Date");
}
isNumeric(attr) → {boolean}
Checks whether an attribute has a numeric type.
Types that are considered numeric are:
Integer
, Long
and Decimal
.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is of Number type, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isNumeric("Count")) {
console.log("Number");
} else {
console.log("not a Number");
}
isObjectReference(attr) → {boolean}
Checks whether an attribute is a reference.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is a reference, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isObjectReference("Mother")) {
console.log("reference");
} else {
console.log("not a reference");
}
isObjectReferenceSet(attr) → {boolean}
Checks whether an attribute is a reference set.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is a reference set, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isObjectReferenceSet("Children")) {
console.log("reference set");
} else {
console.log("not a reference set");
}
isPassword(attr) → {boolean}
Checks whether an attribute is of type Password.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is of Password type, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isPassword("Password")) {
console.log("Password");
} else {
console.log("not a Password");
}
isReference(attr) → {boolean}
Checks whether an attribute is a reference or reference set.
Parameters:
Name | Type | Description |
---|---|---|
attr |
string | attribute to check |
Returns:
true
if attr
is a reference or reference set, false
otherwise
- Type
- boolean
Example
if (mxmetaobject.isReference("Children")) {
console.log("reference or reference set");
} else {
console.log("not a reference or reference set");
}