jump to navigation

How to keep NotesDocument.CopyAllItems under control April 8, 2008

Posted by Jörg Michael in  Notes and Domino . Comments (3)

Now that I have your attention, I can tell you that CopyAllItems is innocent. You just need to be aware of how it works.

I recently came across an application that - for reasons I still don't understand - had a database PostOpen script that would grab your calendar profile from your mail file and .copyallitems to your personal profile document in the other application.

Then some users started getting error messages. Turns out that copyallitems copies all items, as you would expect. Even if the other document already contains items with the same names. So there were mutiple copies of all the items in the profile document. When that happens, the problem is that you will only have access to the first item with that name. Which, after a few changes to that item, is not exactly what you want. Notes doesn't have a problem with multiple items of the same name. It's the formula and Lotusscript APIs that can't deal with it. I understand the C(++) API can handle it.

So, to sum this up: There's nothing wrong with using .copyallitems. Just make sure that the destination document doesn't already have items with the same names.

Comments»

1) Boris - Untitled

should not happen if you use my famous "nudelitem"

greetingz

Bobbele

10.04.2008 15:48:10
2) Thomas Bahn - Untitled

"It's the formula and Lotusscript APIs that can't deal with it."

AFAIK, with NotesDocument.Items you even get access to those hidden items.

Thomas

23.06.2008 14:29:54
3) Joerg Michael - Untitled

I can't see how I could get a hold of them. The help for NotesDocument.GetFirstItem says:

"If multiple items in a document have the same name, programmatic access is limited to the first item. The remaining items yield invalid data. A work-around is to get the first item, process it, remove it, again get the first item (which was the second item), and so on until you process all the items with the same name. If you do not save the document, the items are not actually removed. However, the recommendation is that you avoid creating multiple items with the same name."

It does provide a work-around, yes, but that is one ugly workaround ;-)

Oh, one more thing: I wanted to include this in the original posting, but apparently forgot: .CopyAllItems does have an optional second parameter, replace: Boolean. If True, the items in the destination document are replaced. If False (default), the items in the destination document are appended.

23.06.2008 23:22:56

Discussion for this entry is now closed.