Subject: RE: Gave it a whirl; fell off!
Sadly, I couldn’t get these to work.
The first idea has the same disadvantage as Document.copyToDatabase(…): a real document is created and saved. Whereas a document created with …?OpenForm&ParentUNID=… can be abandoned (via the Back button, for example) with no problem, both the first idea and copyToDatabase(…) require clean-up if the document is abandoned. Still, that’s better than nothing.
I tested by trying to append to an existing document, using a Notes Client:
[Set nd_Original to the Notes Document that will hold the attachment I want to copy]
rt_File1 = nd_Original.createRichTextItem( “FILE1” );
eo_File1 = rt_File1.embedObject( EmbeddedObject.EMBED_ATTACHMENT, null, “d:\uc_midi.gif”, “uc_midi.gif” );
nd_Original.save( true, true );
nd_Original.removeItem( “FILE1” );
nd_Original.save( true, true );
The file did not remain attached during repeated attempts.
I commented-out the last two lines to verify the file was being attached. Then I accidently attached the file again, using a different RichTextItem. Darn. I removed the additional RTI by commenting-out the first save and re-activating the last two lines. Suddenly two(?) $FILE Items appeared - success! I went on to remove the first RTI - and both $FILE Items disappeared.
Further testing along these lines seems to show at least one RTI must remain:
rt_File1 = nd_Original.createRichTextItem( “FILE1” );
rt_File2 = nd_Original.createRichTextItem( “FILE2” );
eo_File1 = rt_File1.embedObject( EmbeddedObject.EMBED_ATTACHMENT, null, “d:\uc_midi.gif”, “uc_midi.gif” );
eo_File2 = rt_File2.embedObject( EmbeddedObject.EMBED_ATTACHMENT, null, “d:\userlist.txt”, “userlist.txt” );
nd_Original.save( true, true );
nd_Original.removeItem( “FILE1” );
//nd_Original.removeItem( “FILE2” );
nd_Original.save( true, true );
This leaves one $FILE Item and the FILE2 RTI - both containing userlist.txt. So I can create a $FILE Item via an RTI (with the help of a second, temporary RTI) but the RTI has to stay as well.
The second idea works in the Notes Client UI? There is no (nor has there ever been a) UI widget(?) for any of these RTIs on the form, but no $FILE Items were automatically created when I ran the agent from a view. But it’s a moot point as this needs to work using a Web Client.
Thanks for your help though, Stan. It will come in handy sooner or later.