Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problem adding script to queryopen event

Status
Not open for further replies.

daveinuk

Technical User
Sep 2, 2005
72
DE
Hi All.

In my query open event I have the following Loutsscript:

Sub Queryopen(Source As Notesuidocument, Mode As Integer, Isnewdoc As Variant, Continue As Variant)
Set cMemoObject = New UIMemoDocument
Call cMemoObject.Init(Source,Isnewdoc)
End Sub

To stop people getting read reciepts from me I have tried to add the lotusscript:

Sub Queryopen(Source As Notesuidocument,
Mode As Integer, Isnewdoc As Variant,
Continue As Variant)
Set uidoc = Source
Set doc = Source.document
Dim workspace As NotesUIWorkspace
Dim RR As Variant
Dim boxType As Long, answer As Integer
If uidoc.IsNewDoc Then
' don't do anything, as this is a new document ...
Else
RR = doc.GetItemValue("ReturnReceipt")
If RR(0) = "1" Then
boxType& = MB_YESNO
answer% = Messagebox("Message configured for Return Reciept. Would you like to send a Return Receipt? (No will temporarily disable Return Receipt)", boxType&, "Continue?" )
If answer% = 7 Then
' determine if the user would like to return the receipt
doc.ReturnReceipt = "0"
Messagebox("Return Reciept disabled. No message will be sent")
'Call doc.save (True, True) enable this if you want to totally disable RR on this message
End If
End If
End If
End Sub

however it tells me that there is an error?

Can anyone tell me what it is and how to solve it?

Thanks.

David.

(using Xp and Lotus Notes R 5.0.1.1)
 
There are two errors I see in your code : first, you are trying to get the value of the ReturnReceipt field, without checking that it exists first.
Indeed, the ReturnReceipt field is only created if the sender sets it, so by querying it without checking for it, you run the risk of the code bombing because the field is not there.

Second, you are modifying the content of a document without ensuring that it was opened in Edit mode. That is a sure-fire way to make the code bomb. Unfortunately, I don't think there are many ways to correct that unless you set the Memo form to open in edit mode automatically.

I would rewrite your code like this :
Code:
Sub Queryopen(Source As Notesuidocument,
Mode As Integer, Isnewdoc As Variant,
Continue As Variant)
Dim workspace As NotesUIWorkspace
Dim RR As Variant
Dim boxType As Long
Dim answer As Integer

If not(source.IsNewDoc) Then
Set doc = Source.document
if doc.hasitem("ReturnReceipt") then
RR = doc.GetItemValue("ReturnReceipt")
If RR(0) = "1" Then
boxType& = MB_YESNO
answer% = Messagebox("Message configured for Return Reciept. Would you like to send a Return Receipt? (No will temporarily disable Return Receipt)", boxType&, "Continue?" )
If answer% = 7 Then
' determine if the user would like to return the receipt
doc.ReturnReceipt = "0"
Messagebox("Return Reciept disabled. No message will be sent")
'Call doc.save (True, True) enable this if you want to totally disable RR on this message
End If
End If
end if
End If
End Sub

Now I must admit I don't like seeing a Save call in the QueryOpen event. I do hope you do not need that.

Another, less complicated way of avoiding the Return Receipts would be to create a new column in the Inbox folder that flags documents that have the ReturnReceipt field set to "1".
When you see such messages, replicate locally, set your location to Island, read those messages, delete the receipts from your local mailbox, then set back to Office and re-replicate.
Of course, it is a lot more manual like that, and prone to error and forgetting. So maybe your idea is better anyway :).

Pascal.
 
hi, thanks for the info, however its still not working.

I have some issues with the a byval on the first line

any ideas?

(im not up with my coding on LN and am having trouble importing the issues as they are not copyable)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top