How to programatically copy a doc to Rich Text w/Script

I have an application that creates price quotes, and each time one of the price quote forms is edited I’d like to save the old quote in a seperate archive database.

Trouble is, I can’t figure out how to do it.

I’m aware of similar capabilities that Notes has that are pretty close to this, but I’m wondering if the wizards in netland are aware of a better way.

  1. Save previous version as a response document

Keep in mind that I’d like to save the previous price quote to a second database. I guess I could set up the form to save the previous version as a response, then in one of the form events copy the document to the archive database and then delete it from the quote database.

  1. Inherit entire form to rich text field

This is largely a manual process, so I’d have to somehow automate the creation of the new document with uiworkspace commands in lotusscript, then copy the document to the archive database.

  1. Some kind of import / export using files or XML

I know that I can export a document to a file, and then import it to a rich text field. That works pretty well manually, and maybe there is a way to automate that using uiworkspace commands in lotusscript.

  1. Use a mail-in db and forward the whole form.

The mail form doesn’t have all of the fields that I need, but maybe I can change that.

I’d like to be able to do something like this:

varient = notesdocument.copy

archive = archiveDB.create

call archive.setRTItem("old quote", varient)

But, there aren’t methods like this as far as I know.

Subject: I suggest that you look at the NotesDocument.CopyToDatabase example in the help. All the info you need is there.

Combine that with the NotesUIDocument.QuerySave/NotesUIDocument.QueryClose events to provide the Call when the user actually saves and closes the document…

Subject: How to programatically copy a doc to Rich Text w/Script

  1. Use a mail-in db and forward the whole form.

The mail form doesn’t have all of the fields that I need, but maybe I can change that.

This will work. There’s no rule that says that a mail-in db has to be created from a mail template. You can specify the form field and use your form rather than a Memo one. Alternatively, use a mail db and store the form with the document.

That being said, it’s not all that difficult to just create the document in the second database directly anyway. Here’s a bit of example code to get you started.

Dim session As New NotesSession
Dim Sourcedb As NotesDatabase

Dim Targetdb as NotesDatabase
Dim Sourcedoc As NotesDocument

Dim Targetdoc As NotesDocument
Set Sourcedb = session.CurrentDatabase

Set Targetdoc = Targetdb.CreateDocument

Targetdoc.Subject = Sourcedoc. (Repeat until all wanted fields done - useful if you only want to copy some of the fields over)

or

Call Sourcedoc.CopyAllItems(Targetdoc, True)

Call Targetdoc.Save( True, True )

As a second method (dpeending on what you want to achieve exactly)

Dim TargetDb As New NotesDatabase( “”, “” )
Dim Sourcedoc As NotesDocument


Call Sourcedoc.CopyToDatabase( TargetDb )

Stephen Lister

Subject: RE: How to programatically copy a doc to Rich Text w/Script

Ahhh, these are some interesting ideas that I had not considered. RenderRTItem / CopyAllItems.

Thank you both.

I’ll give both of these ideas a shot in a day or so and post the results back here.

Subject: How to programatically copy a doc to Rich Text w/Script

Take a look at RenderToRTItem