I would like to copy a form from one NSF to another NSF programmatically. I am aware that the NotesDocument class has the CopyToDatabase method, and the NotesDatabase class has the CreateView method.
However, I have not found anything to allow me to add a form to an NSF.
I am using Lotus Notes 8.5.2, COM, and C#.
I have no problem retrieving information about forms or deleting them, and I have the following code snippet:
//NotesConnectionDatabase and nd2 are objects of type NotesDatabase and are
//members of the same session.
//Write the name of each form to the console.
//Delete each form from the database.
for (int i = 0; i <= (((object[])NotesConnectionDatabase.Forms)).Length - 1; i++)
{
Console.WriteLine(((NotesForm)((object[])NotesConnectionDatabase.Forms)[i]).Name);
((NotesForm)((object[])NotesConnectionDatabase.Forms)[i]).Remove();
}
//For each form in nd2, copy the form to NotesConnectionDatabase.
for (int j = 0; j <= (((object[])nd2.Forms)).Length - 1; j++)
{
//I am aware that there is no such method as NotesForm.CopyToDatabase
((NotesForm)((object[])nd2.Forms)[j]).CopyToDatabase(NotesConnectionDatabase);
}
Using the
NotesNoteCollectionclass you can get a collection of the forms. TheSelectFormsproperty should be set toTRUEand the rest should be set toFALSE.After building the
NotesNoteCollectionit will contain a collection of form (documents) that can be accessed like this:The document can be copied with the
CopyToDatabasemethod