Developer Documentation Library > Data Model > Extending the UNICOM Intelligence Data Model > Creating a Metadata Source Component (MDSC) > Populating the MDM Document > Versions
 
Versions
The version feature enables you to keep track of variations of a questionnaire used in a single project. The metadata Document that you see is controlled by the Document.CurrentVersion property.
However, you do not have to link all objects in the metadata to a particular version: you can define some objects as unversioned. An unversioned object can be changed at any time, regardless of the lock status of the current version. Only versioned objects can be included in the routing of a questionnaire, which means that all of the questions that are used for collecting data must be versioned. Unversioned objects are typically used for coding variables, so that as new categories are created, they can be used when coding data collected using previous versions of the Document. You define whether an object is versioned or not by setting its Versioned property to True or False.
To create and populate a new version, you would typically:
1 Use the Version.Lock method to lock the current version.
2 Use the Versions.AddNew method to create a new version. This creates a new version that is identical to the previous version.
3 If necessary, delete all of the versioned objects from the new version. You would typically do this by looping through the Document's Fields collection using the Fields.Remove method. For example, in Visual Basic:
Dim MyDocument As MDMLib.Document
Dim MyFields As MDMLib.ITypes
Dim i As Long

Set MyFields = MyDocument.Fields

For i = MyFields.Count - 1 To 0 Step -1
MyFields.Remove i
Next i
And in Visual C++:
MDM::ITypesPtr pFields = pDoc->Fields;
for (long i = pFields->Count - 1; i >= 0; --i)
{
pFields->Remove(i);
}
4 Populate the Document with the questions for the new version.
5 Save the Document.
See also
Setting up the document
Setting up basic questions
Setting up elements
Setting up helper fields
Setting up shared category lists
Setting up complex questions
Setting up the routing
Setting up custom properties
Using the Alias Map component
Visual C++ examples
Populating the MDM Document