Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > Working with metadata versions > Activating a version
 
Activating a version
This topic provides a mrScriptBasic example that calls the Document.Join method to merge a version of an .mdd file in a similar way to that which occurs when you activate UNICOM Intelligence Interviewer projects for the second and subsequent time. This type of merge is different from the merge that occurs when you select multiple versions, where the superversion that is created is the union of the merged versions.
A typical UNICOM Intelligence Interviewer scenario is:
The project is developed on a scriptwriter's computer using the desktop tools or in the user folder using the UNICOM Intelligence Interviewer - Server Admin applications.
The project is activated for the first time. This process includes the project's .mdd file being copied to the FMRoot\Master folder.
Additional changes are made to the project, for example adding or deleting questions and categories.
The project is reactivated. This process includes the changes in the new version of the .mdd file on the scriptwriter's computer or in the user folder being merged into the latest version of the .mdd in the FMRoot\Shared folder and then copied to the FMRoot\Master folder.
The merge of the metadata involves the following:
The transfers the latest version of the updated (scriptwriter's) .mdd file (the secondary file) to a new version in the .mdd file in the FMRoot\Shared folder (the master file).
The merging of the labels and properties in the previous version of the master file into this new version. This means that the variable and category definitions in this new version are as defined in the scriptwriter's file, but if any translations or custom properties are missing in the scriptwriter's file, they are supplied by the server file. In addition, the category map from the server file is preserved to maintain data consistency.
The following example performs these same steps and uses the following files and assumptions:
Master file. short_drinks_version4.mdd, as created in Extracting a single version to a new .mdd file.
Secondary file. short_drinks.mdd.
Dim MyMasterDocument, fso, MyJoinOptions

Const TARGETDOC = "C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\short_drinks_joined_versions.mdd"

' Work on a copy of short_drinks_version4.mdd file so that
' we do not update the original file
Set fso = CreateObject("Scripting.FileSystemObject")
fso.CopyFile("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Output\short_drinks_version4.mdd", _
TARGETDOC, True)

' Create the MDM object and open the copy of
' short_drinks_version4.mdd in read-write mode
Set MyMasterDocument = CreateObject("MDM.Document")
MyMasterDocument.Open(TARGETDOC, , MDMLib.openConstants.oREADWRITE)

' Ensure there is a version and that it is unlocked
If MyMasterDocument.Versions.Count = 0 Then
MyMasterDocument.Versions.AddNew()
ElseIf MyMasterDocument.Versions.Latest.IsLocked Then
MyMasterDocument.Versions.AddNew()
End If

' Create a value for the join options parameter
' using the UNICOM Intelligence BitOr function
MyJoinOptions = BitOr(MDMLib.joinOptionConstants.joFullLCL, _
MDMLib.joinOptionConstants.joFullDataSources, _
MDMLib.joinOptionConstants.joSkipUndoOnFail, _
MDMLib.joinOptionConstants.joFullUnversioned)

' Merge in the short drinks sample .mdd file
MyMasterDocument.Join("C:\Program Files\IBM\SPSS\DataCollection\7\DDL\Data\Mdd\short_drinks.mdd", _
, MDMLib.joinTypeConstants.jtRight, MyJoinOptions)

'Lock version
MyMasterDocument.Versions.Latest.Lock()
MyMasterDocument.Save()
MyMasterDocument.Close()
Requirements
UNICOM Intelligence Data Model
See also
Adding versions to the Short Drinks Example .mdd
Extracting a single version to a new .mdd file
Working with multiple versions
Working with metadata versions