Professional > Table scripting > Working with Change Tracker > Change Tracker: Modifying metadata in a new table document
 
Change Tracker: Modifying metadata in a new table document
Sample Script File: ChangeTrackerTest1_NewDocument.mrs
This example script is based on the Museum sample data set. See Running the sample table scripts for information on running the example scripts.
This example script demonstrates how to modify metadata and save the modifications to a table document file. The saved .mtd file is used by the ChangeTrackerTest2_OpenDocument.mrs script in Change Tracker: Modifying metadata in an existing Table Document.
The script produces the following tables:
Change tracker using the modified 'before' field
Change tracker using the renamed field 'gender_new'
The following script modifies the before field, renames the gender field, creates a new folder, and moves the fields age, before, and visits into the new folder:
' Modify field
Dim oField
Set oField = MDMDoc.Fields["before"]
oField.AxisExpression = "{base(), Yes, No, comb 'Answered' combine({Yes, No}), Not_answered}"
ChangeTracker_ModifyField(TableDoc, oField)

' Rename field
Set oField = MDMDoc.Fields["gender"]
Set oField = ChangeTracker_RenameField(TableDoc, oField, "gender_new")

' Create folder
Dim oFolder
Set oFolder = ChangeTracker_CreateFolder(MdmDoc, "Folder1", 0)

' Move field to folder1
Set oField = MdmDoc.Fields["age"]
ChangeTracker_MoveFieldToFolder(MdmDoc, oFolder, oField)
Set oField = MdmDoc.Fields["before"]
ChangeTracker_MoveFieldToFolder(MdmDoc, oFolder, oField)

' Add field to folder1
Set oField = MdmDoc.Fields["visits"]
ChangeTracker_AddFieldToFolder(MdmDoc, oFolder, oField)
See also
Working with Change Tracker