Hi Forum,
i guess that I have an easy issue.
I want to realise that every person only can create one response document per main document.
I don’t have any code yet. May be it is hidden somewhere in the form properties.
Regards
Sönke
Hi Forum,
i guess that I have an easy issue.
I want to realise that every person only can create one response document per main document.
I don’t have any code yet. May be it is hidden somewhere in the form properties.
Regards
Sönke
Subject: Create only one response document
As far as I know Notes has no default option for this. You will have to manually check this.Under the button that creates a new response document first do a check like this.
Assuming the response document has a field on it with the original author, lets call it ‘ORIGINALAUTHOR’
Assuming the parent document is currently opened:
Sub Click()
Dim Session as New NotesSession
Dim ws as new NotesUiWorkspace
Dim collection as NotesDocumentCollection
Dim currentResponse as NotesDocument
Dim allowCreation as Boolean
allowCreation = true
Set collection=doc.Responses
Set currentResponse=collection.GetFirstDocument
While Not ( currentResponse Is Nothing or allowCreation = True)
if currentResponse.ORIGINALAUTHOR(0) = session.UserName then allowCreation = False
Set currentResponse=collection.GetNextDocument( currentResponse )
Wend
If allowCreation Then
Call ws.compose.....
Else
Msgbox "Only 1 response allowed per user"
End if
Subject: Create only one response document
I do have such field an the parent document is opened.
The code seems logical to me but I always recieve the dialog:
“illegal executable code at the module level”
any idea?
regards
Subject: RE: Create only one response document
debug your script and see on what line the error occurs?
Subject: RE: Create only one response document
I tried to but the debugger doesn’t even open.
Subject: Create only one response document
May be I implemented it wrong. could you please write down how to do it? thanks
regards
Sönke
Subject: Create only one response document
Found the error: Correct code is:
Sub Click(Source As Button)
Dim Session As New NotesSession
Dim ws As New NotesUiWorkspace
Dim collection As NotesDocumentCollection
Dim currentResponse As NotesDocument
Dim allowCreation As Boolean
allowCreation = True
Set collection= ws.CurrentDocument.Document.Responses
' If there's no answer at all just compose a response
If collection.Count = 0 Then
Call ws.ComposeDocument(,,"frm_res_policy")
' If there are any responses check if the current user already created a response
Else
Set currentResponse=collection.GetFirstDocument
While Not ( currentResponse Is Nothing Or allowCreation = False)
If currentResponse.Authors(0) = session.UserName Then allowCreation = False
Set currentResponse=collection.GetNextDocument( currentResponse )
Wend
If allowCreation Then
Call ws.ComposeDocument(,,"frm_res_policy")
Else
Msgbox "Only 1 response allowed per user"
End If
End If
End Sub
Regards Sönke