Hi,I want to copy some documents from one database to another database (these databases have the same design); I have many fields in the form, and only one field I don’t want to copy(this field is RT, and contains much content, so I want to set the value as BLANK when I copy to save time). Do you have an easy way to do this?
Right now I can only think to get the doc collection from the first databse, then for each of them, create a new doc in the second database, define the form name, and set all the fields value same as that doc; for that specific field I would set “” .
I don’t want to copy this field, because each doc contains many attachments in this field, and I don’t want to waste time on copying it, since I don’t need it.
There are so many fields in this form, so it seems a little complex.
You’re already using the notesdocumentcollection to navigate through the documents yo want to copy, right?
Why don’t you just copy the full documents then access the copied documents using a collection? Then you could use the StampAll method to get hid of the field you don’t want to store? This way you won’t need to set target documents one by one, you could just use the doc.CopyToDatabase method while navigating through your origin document collection. Then, the stampAll method could take care of the unwanted field real fast. Like this:
db1, doc1, col1 as origin, db2, col2 as destination, ok?
'The full copy
For i = 1 to col1.count
Set doc1 = col1.GetNthDocument(i)
Call doc1.CopyToDatabase(db2)
next
'blanks the field
Set col2 = db2.getdocumentsbykey(somekey)
Call col2.StampAll(“unwantedfield”, “”)
Think it can help you?
But if anyone knows how to do it better, let us know, I got real curious about this… =^.^=
Thanks for your advice, Charlotte.However, as I said, the unwantedfield contains too many attachments, and it will take a long long time to copy all the fields before I replace that field. That’s not what I want. Other fields are quite simple, and quite fast to be copied, except this specific one. That’s the reason I want to replace the value of that field before copying.
You could use the Items property of notesdocument then. have you ever used it before: It’s simple, good for creating fields one by one without having to know each one’s name.
Forall i In doc.Items
if i.name <> “unwantedfieldname” Then
item.CopyItemToDocument( newdoc, item.name )
end if
End Forall
this way you’re still copying the items individually, but you’re skipping lots of code… what do you think of it?
Do what Charlotte says, but instead of copying each item individually, delete the RichtextItem from the source document, then use CopyAllItems to copy the data across to a newly created destination document. As long as you don’t SAVE the source document you deleted the RichtextItem from, it will not delete any of your attachments. Just go onto the next source document normally, without saving your changes, and all will be well. Naturally you -do- want to save the new destination document, just do -not save the original-.- Richtext is funny in Notes, though, so this -may- copy the richtext contents even though the item has been deleted, because it might do the copy from the data store directly instead of the in-memory document. Try it and kick out of the loop after a few iterations, then look at the result.
Domino creates those fields automatically, if there is any attachment associated with a Notes document. If you copy items and remove RT field, these unnnecessary internal fields also get copied unless you remove them.