Developer Documentation Library > Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > MDM custom properties
 
MDM custom properties
All of the main MDM object types (Document, Variable, Grid, Element, and so on) have a Properties collection to store custom properties, which are used to store information that is not directly supported by the Metadata Model. For example, SPSS Statistics SAV DSC uses a number of custom properties to control things like the Yes and No values in a multiple dichotomy set when you export data to a .sav file.
Custom properties are stored for a particular user context. This means that you can store different values of the same custom property for use in different user environments, such as interviewing or analysis.
Except when the Properties collection is attached to an unversioned object, the Properties collection is always under version control. This means that the custom properties are associated with a particular version and cannot be changed when that version is locked. However, many of the objects also have a DataSourceProperties collection for storing custom properties that are DataSource-specific and this collection is unversioned.
Custom properties on the VariableInstance object inherit from the associated variable. Similarly, custom properties on the ElementInstance object inherit from the associated Element object. However, if context alternatives have been set up for the current user context, MDM searches for the custom property in the alternative contexts before searching the custom properties on the associated variable or element.
For example, in a Document with only one user context, suppose you use this mrScriptBasic statement to create a custom property called MyProperty on a variable called Q1 and set the value of MyProperty to 1:
MyDocument.Fields["Q1"].Properties.Item["MyProperty"] = 1
The associated VariableInstance will automatically have a custom property called MyProperty with a value of 1. However, the count of the VariableInstance object's Properties collection will be zero. You can demonstrate this using this code:
Debug.Log(MyDocument.Variables["Q1"].Properties["MyProperty"])
Debug.Log(MyDocument.Variables["Q1"].Properties.Count)
If you now set the value of the custom property to 2 on the VariableInstance, the MyProperty custom property will have a value of 1 on the variable, 2 on the VariableInstance, and the count of the VariableInstance.Properties collection will now be 1:
MyDocument.Variables["Q1"].Properties.Item["MyProperty"] = 2
Debug.Log(MyDocument.Variables["Q1"].Properties["MyProperty"])
Debug.Log(MyDocument.Variables["Q1"].Properties.Count)
Debug.Log(MyDocument.Fields["Q1"].Properties["MyProperty"])
Similar examples in VB.NET are:
MyDocument.Fields("Q1").Properties("MyProperty") = 1
Debug.Write(vbCrLf & MyDocument.Variables("Q1").Properties("MyProperty"))
Debug.Write(vbCrLf & MyDocument.Variables("Q1").Properties.Count)
MyDocument.Variables("Q1").Properties("MyProperty") = 2
Debug.Write(vbCrLf & MyDocument.Variables("Q1").Properties("MyProperty"))
Debug.Write(vbCrLf & MyDocument.Variables("Q1").Properties.Count)
Debug.Write(vbCrLf & MyDocument.Fields("Q1").Properties("MyProperty"))
If you now change the value of the MyProperty custom property to 3 on the variable, the value of the MyProperty custom property will remain set to 2 on the VariableInstance.
In summary, custom properties on a VariableInstance object inherit from the associated Variable object. This means that custom properties set on the Variable object actually exist on the VariableInstance, even though the Count property on the VariableInstance Properties collection object does not reflect this. If you change the value of the custom property on the Variable, the value of the same custom property on the VariableInstance is also changed. However, if you write a new value to the custom property on the VariableInstance, it “branches off” on its own and no longer inherits its value from the custom property on the Variable. Any subsequent changes to the custom property on the Variable have no effect on the value of the custom property on the VariableInstance.
Custom properties on an ElementInstance object inherit from the associated Element object in exactly the same way. In addition, DataSourceProperties inherit from the Properties collection in a similar way.
For information about iterating through the custom properties of an object, see Iterating through custom properties.
See also
DataSourceProperties
Viewing custom properties in MDM Explorer
Iterating through custom properties
Custom properties in use in UNICOM Intelligence products
Custom properties used for card and column information
Setting UNICOM Intelligence Interviewer - Paper looks in the MDM Document
Working with card and column definitions
HTMLDocType and HTMLOptions custom properties
Working with the Metadata Model