Attribute.parseFromMd

Syntax

parseFromMd(md: Object);

Parameters

md. Dictionary element settings in metadata format.

Description

The parseFromMd method gets settings of MDM dictionary attribute from specified object in metadata format.

Example

To execute this example, the page must contain the DictionaryBox component named dictionaryBox (see Example of creating the DictionaryBox component ). Create an invisible translation attribute and add it to MDM dictionary:

// Get MDM dictionary
var source = dictionaryBox.getSource()[0];
// Create a new attribute
var newAttr = new PP.Rds.Attribute({
    Owner: source
});
// Define attribute settings
var newAttrMd = {
    id: "LastEditingDate_EN",
    k: 1806,
    kind: PP.Rds.AttributeKind.Common,
    n: "Date of last change",
    nullable: false,
    predefined: PP.Rds.PredefinedAttribute.None, // Attribute is not predefined
    dt: PP.Mb.DbDataType.DateTime,
    vis: false // Make the attribute invisible
};
// Get attribute settings from JSON object
newAttr.parseFromMd(newAttrMd);
// This attribute is a translation attribute
newAttr.setIsTranslation(true);
// Add created attribute to metadata
source._AttrsById[newAttrMd.id] = source._AttrsByKey[newAttrMd.k] = newAttr;
var metadata = source.getMetadata();
var attrsArr = PP.getProperty(metadata, "attrs.its.it");
attrsArr.push(newAttrMd);
// Refresh the tree of dictionary elements
dictionaryBox.getDataArea().getActiveDictTree().refreshAll();
console.log("Default value for the attribute: %s", source.getAttribute(1806).getDefaultValue());

After executing the example a hidden translation attribute is created in MDM dictionary. Attribute key is 1806, and attribute name is LastEditingDate_EN. The browser console shows default value for this attribute:

Default value for the attribute: 2013-11-01T12:21:45.399Z

See also:

Attribute