Your Development & Design Resource

View PostPaste and the active/inactive toggle

While working on Project: Yellowcake, which (read: another hint) falls under the classification of a utility, I came across an interesting need.

Let's say you have an engine that looks to active documents for it's tasking. You can (and I have) simply control what's active by this definition by utilizing and accounting for a status toggle - active:inactive - which will allow the user to enable/disable a given document while keeping said document in the application. Pretty standard stuff, really...

But what happens when someone copy/pastes an active document? You have, until they modify the pasted or source document(s) duplicate tasking documents in your engine!

See, if I allow the user to copy/paste a given document into an active engine, it could produce some pretty serious side effects - the least of which being that the application simply doesn't work.

And the truth is this wasn't a problem, and kinda wouldn't be, unless you have a very aggressively scheduled or manually triggered Domino agent (manuallly triggered would apply to Project: Yellowcake here) grabbing all active documents. So the answer was to simply flag each pasted document as inactive, and to do that, I've added the following code to the PostPaste events of my UI Views:

Sub Postpaste(Source As Notesuiview)

 Dim s As New NotesSession
 Dim db As NotesDatabase
 Dim dc As NotesDocumentCollection
 Dim pdoc As NotesDocument

 Set db = s.CurrentDatabase
 Set dc = source.Documents

 If (dc.Count > 0) Then
  Set pdoc = dc.GetFirstDocument
  Do Until pdoc Is Nothing
   If pdoc.status(0) = "active" Then
    Call pdoc.ReplaceItemValue("status", "inactive")
    Call pdoc.Save(True, False, True)
   End If
   Set pdoc = dc.GetNextDocument(pdoc)
 End If

End Sub

Very simple, and get's the job done quick and easy-like!

You can use the same methodology to allow your application users to quickly duplicate documents, while pre-setting and/or clearing certain functional or would-be-unique fields!

- Update -

Check out the comments: source refers to the copied documents, not the pasted documents. And while this might still work in my application, it warrants pointing out this huge misconception on my behalf!!

For more information, check out Andre's Querypaste, a popular misconception, and of course the comments in this post!

About the author: Chris Toohey

Thought Leadership, Web & Mobile Application Development, Solutions Integration, Technical Writing & Mentoring

A published developer and webmaster of, Chris Toohey specializes in platform application development, solutions integration, and evangelism of platform capabilities and best practices.

More from is powered by IBM Notes Domino XPages & hosted by Prominic.NET

Contact Us

Use our Contact / Feedback form or one of these email addresses:

Creative Commons License

Except where otherwise noted, by Chris Toohey is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.