Does anyone know if it is possible to copy a Form from one db to another programmatically in script? I do not know C ++. Thanks
Janice
Does anyone know if it is possible to copy a Form from one db to another programmatically in script? I do not know C ++. Thanks
Janice
Subject: Copy a Form from one db to another
Lookup NotesNoteCollection in the Domino Desginer help. It is a way to access an index of some or all design elements in a db, much like a NotesDocumentCollection is a way to access an index of some or all documents in a db.
Using NotesNoteCollection, you can get get a NotesDocument object that actually represents the form, and then copy it to another db the same way you would copy a document.
The one thing you need to be aware of is that if the form contains subforms, shared fields, uses script libraries or other resources, you will have to copy those too.
-rich
Subject: RE: Copy a Form from one db to another
That’s awesome…its there…I SEE it…but can’t quite…reach…
I have never worked with NotesNote before and can’t quite figure out how to access the object (or document property) of the Note. Anything good to read on the Web about accessing this that you know of? Methods just don’t seem to do it.
Thanks again
Janice
Subject: RE: Copy a Form from one db to another
You would use NotesNoteCollection.GetFirstNoteID() and getNextNoteID() to loop through the collection. For each NoteID, use NotesDatabase.GetDocumentByID(NoteID) to get a NotesDocument representing the form. To see if it is the one you are looking for, use NotesDocument.GetFirstItem(“$Title”), which gives you the name of the form. When you find a match, use NotesDocument.CopyToDatabase(otherDb).
-rich
Subject: RE: Copy a Form from one db to another
Thats great! I didn’t know if I could do it that way. What I ended up doing (for anyone else who is looking at doing this) is using the exporter and then importer to do it. It works, but I wonder if I like your way better. My script is:
Dim stream As notesstream
Dim exporter As NotesDXLExporter
Dim importer As NotesDXLImporter
Dim nc As NotesNoteCollection
Dim getForm As NotesForm
Set nc = db2.CreateNoteCollection(False)
Set getForm=db2.GetForm(formCheckName)
Call nc.add(getForm)
Set stream=s.CreateStream
Call stream.Open("c:\temp" & formCheckName)
Set exporter=s.createDXLexporter(nc, stream)
Set importer=s.createDXLimporter(stream, db)
importer.designimportoption=dxlimportoption_replace_else_create
Call exporter.process
Call importer.process
Call stream.close
The name then needs to be deleted between runs from the C:\temp file, so I used the form name for the export. This should work since if the form exists, it should never kick off. Thanks for your suggestion!!!
P.S. I got this from a white paper which is, of course, one of our best resources next to this forum!!
Subject: RE: Copy a Form from one db to another
Found it! Wow that is awesome. Thanks for your help!!!