Developer Documentation Library > Data Model > Accessing the UNICOM Intelligence Data Model > Working with the Metadata Model > Working with the Metadata Model: Tutorial > Cloning shared lists, pages, and blocks
 
Cloning shared lists, pages, and blocks
The following example demonstrates how to clone a shared list. The example can be modified to clone pages and blocks.
Dim mdmdoc
set mdmdoc = createobject("mdm.document")
mdmdoc.Script = "!
Metadata(en-us, question, label)
list1 define {a,b,c,d,e};

q1 "q1" categorical {use list1};
end metadata
!"
mdmdoc.Save("temp.mdd")
mdmdoc.Close()

set mdmdoc = createobject("mdm.document")
mdmdoc.Open("temp.mdd")

'create new document to store the new shared list
Dim newDoc
Set newDoc = createobject("mdm.document")
newDoc.Contexts.Base = "Question"
newDoc.Contexts.Current = "Question"
newDoc.IncludeSystemVariables = true

dim list, listClone, newClonedList
set list = mdmdoc.Types["list1"]
set listClone = list.GetInterface("{F2780F44-AC4C-4afa-A429-30E817C05D37}")
set newClonedList = listClone.CloneEx[newDoc][null]
newDoc.Types.Add(newClonedList)

Dim newVar
Set newVar = newDoc.CreateVariable("newQ1", "new label for q1")
newVar.DataType = 3 ' mtCategorical
Dim newElement
Set newElement = newDoc.CreateElements("lst","")
Set newElement.Reference = newdoc.Types["list1"]
newElement.Namespace = false
newVar.Elements.Add(newElement)
newDoc.Fields.Add(newVar)
newDoc.Save("newDoc.mdd")
debug.Log(newDoc.Script)
See also
Working with the Metadata Model: Tutorial