Copy DB elements from DB to DB

How would one copy design elements from one DB to another via code?Example, I am trying to copy an agent from one DB to another db.

I need to copy some not all:

Agents

Views

Forms

How does one do this?

LotusScript or Java does not matter

Please help!!!

Subject: Copy DB elements from DB to DB

You can use DXL to export and import design elements from one database to another. You should look into the following classes:

NotesNoteCollection

NotesDXLExporter

NotesDXLImporter

It might be easier to manually export the selected elements to a dxl file(s) first. This could be done using the menu option from within Designer by going to Tools->DXL Utilites->Exporter. Then use an agent to import dxl with your design elements into other databases.

Subject: RE: Copy DB elements from DB to DB

I saw samples on how to do this, was hoping to locate something a little simpler if possible

Subject: RE: Copy DB elements from DB to DB

I guess you can access design elements as notes document still via NotesNoteCollection and copy to target databases.

Dim nc As NotesNoteCollection

Set nc = db.CreateNoteCollection(False)

nc.SelectAgents = True

nc.SelectForms = True

nc.SelectViews = True

Call nc.BuildCollection



nid = nc.GetFirstNoteId

For i = 1 To nc.Count

	nextid = nc.GetNextNoteId(nid)

	Set doc = db.GetDocumentByID(nid)

	If doc.GetItemValue("$Title")(0) = "myElement" Then

		Call doc.CopyToDatabase( copydb )

	End If

	

	nid = nextid

Next

Subject: little more complicated method (maybe more flexible?..code included)

FIRST ADD THIS AGENT TO YOUR DB AND RUN IT================================================

%REM

This agent updates two main views…

1.)    FormList

2.)    ViewList

…so that they show Forms/Subforms in one and Views in another

It does this by modifying the $FormulaClass field on the two views so that:

"4" = show forms and subforms

"8" = show views, folders, and navigators

%END REM

Dim s As New NotesSession

Dim db As NotesDatabase

Dim view As NotesView

Dim doc As NotesDocument



Set db = s.CurrentDatabase

'FIRST - UPDATE THE VIEW THAT IS SUPPOSED TO SHOW FORMS AND SUBFORMS	

Set view= db.GetView("FormList")	

If view Is Nothing Then Exit Sub

Set doc = db.GetDocumentByUNID(view.UniversalID)

If doc Is Nothing Then Exit Sub

Call doc.ReplaceItemValue("$FormulaClass", "4")

Call doc.Save(True, True)



'SECOND - UPDATE THE VIEW THAT IS SUPPOSED TO SHOW VIEWS, FOLDERS, AND NAVIGATORS

Set view = db.GetView("ViewList")

If view Is Nothing Then Exit Sub

Set doc = db.GetDocumentByUNID(view.UniversalID)	

If doc Is Nothing Then Exit Sub

Call doc.ReplaceItemValue("$FormulaClass", "8")

Call doc.Save(True, True)

NOW CREATE THE FORMLIST VIEW AND PUT THIS IN THE FIRST COLUMN

===============================================

@If(

$Flags = “#34CQ”;“Framesets”;

$Flags = “34CiQ”;“.jpg”;

$Flags=“C”|$Flags=“” | $Flags=“CD”;“Forms”;

@Left($Flags;3) = “CUA”;“SubForms”;

$Flags=“C34WQ”;“Outline”;

$Flags=“C34yQ”;“Shared Actions”;

“Unknown”)

NOW CREATE THE VIEWLIST VIEW AND PUT THIS IN THE FIRST COLUMN

===============================================

@If(

$Flags=“Y”;“Views”;

$Flags=“PY”;“Views”;

“Other”)