IBM®
Skip to main content
    Country/region select      Terms of use
 
 
   
     Home      Products      Services & solutions      Support & downloads      My account     

developerWorks  >  Lotus  >  Forums & community  >  Best Practice Makes Perfect

Best Practice Makes Perfect

A collaboration with Domino developers about how to do it and how to get it right in Domino

I was reminded today about a misconception I've run across among Domino developers, and I thought it would be a good thing to mention here. It's quite natural to assume that in a Querypaste event of a view, you can use NotesUIView.Documents to get a list of the documents being pasted.

Nay nay!

This only appears to work because often people only test the Querypaste event by copying and then immediately pasting documents in the same view. During this event, the Documents property actually contains a list of the documents selected in the view -- not the documents being pasted. So it's no use in catching documents pasted from other applications to make sure they're using a known form, for instance. You can only look at specific pasted documents after they have been pasted (use Postpaste or an agent set to run on pasted documents). By then, of course, it's too late to do anything about them unless you have access both to read them, and to make whatever corrections might need to be made (edit/delete docs).

What? Wait! You can paste a document you don't have read access to? How? This happens when there's a Readers field in it that doesn't list you by name, but by role or group, and your roles and groups at your destination are different than in the source. It's a problem even if you have Manager access to the destination database -- if the Readers item doesn't list you, you can't see the document not nohow, including in the Postpaste event or agent.

It would, of course, be nice to be able to mess with the document's items (to make sure the user could still read or edit the document later) before they are written to disk. It also would help to get a chance to decide whether to allow the paste based on the contents being pasted.

Alas, there's no way to do this with LotusScript. I suppose it could be done using the Notes C API, by registering event hooks (EMRegister) -- though I haven't tried. This is tricky to do as part of an NSF design -- you'd need to install a DLL (or your OS' equivalent) on people's workstations.

Your best bet in most cases is to just turn pasting off (Continue = False) and provide view actions to do any "approved" types of document copying.

Andre Guirard | 10 January 2008 01:46:14 PM ET | Plymouth, MN, USA | Comments (8)


 Comments

1) There is a way....
Art Zoutendijk | 1/23/2008 5:46:19 PM

As far as I can see, copied documents will temporarily stored in the file "~clipbrd.ncf". You can create a db handle to this database and "check" the content.

This is also very handy when you want to avoid pasting "large" documents, BEFORE the actuall action has taken place.

Art

2) re: There is a way....
Andre Guirard | 1/24/2008 6:55:02 AM

OMG that is outstanding! I'll have to see if I can get that mentioned in the help (they might think it sounds too much like a kludge).

3) re: There is a way....
Kerr | 1/24/2008 7:10:24 AM

That sounds more like a "Righteous HackĀ®" to me ;)

{ Link }

4) Querypaste, a popular misconception
GB | 6/7/2008 7:34:43 PM

It is dissapointing that QueryPaste has never worked as everyone would naturlaly expect it to.

FYI *R3* pastemacros let you check *before* the document is put in the database.

So I have a template database with an R3 pastemacro that I use design refresh to incorporate into any database. Only catch is you have to maintain it with an R4 client (which retains the R3 nature of the agent).

A bit of rigmorole but once set up is quite resuable.

5) Querypaste, a popular misconception
Andy Dempster | 8/6/2008 7:04:56 AM

For the copy and paste crowd:

Sub Querypaste(Source As Notesuiview, Continue As Variant)

'***HARD CODE ALERT!***

'/* grab the clipboard as a database object

Dim dbToCheck As NotesDatabase

Set dbToCheck = New NotesDatabase("", "~clipbrd.ncf")

'/* if the db is not present - make generic

If Not (dbToCheck.IsOpen) Then

varQuery = Messagebox _

("Are you sure you wish to duplicate these documents?", _

4 + 32 + 0, _

"Paste operation")

Else

'/* specific message regards copy/paste

Dim intDocCount As Integer

intDocCount = dbToCheck.AllDocuments.Count

'/* generic message for single doc

If intDocCount = 1 Then

varQuery = Messagebox _

("Are you sure you wish to duplicate this document?", _

4 + 32 + 0, _

"Paste operation")

Elseif intDocCount > 1 Then

varQuery = Messagebox _

("Are you sure you wish to duplicate " & Cstr(intDocCount) & " documents?", _

4 + 32 + 0, _

"Paste operation")

Else

'panic!

End If

End If

'/* do we prevent paste? (formally coded)

If ( varQuery = 7) Then

Continue = False

Set dbToCheck = Nothing

Exit Sub

Else

Continue = True

Set dbToCheck = Nothing

Exit Sub

End If

End Sub

6) thanky
vgasedas | 4/18/2015 3:52:03 AM

{ Link }

7) Thanks!
Hes | 11/20/2015 4:33:34 AM

This made my life so much easier ! thanks muchness

 Add a Comment
Subject:
   
Name:
Comment:  (No HTML - Links will be converted if prefixed http://)
 
Remember Me?     Cancel

Search this blog 

Disclaimer 

    About IBM Privacy Contact