Subject: RE: I want to create document using NEWENTRY_REQUEST event
I want to select a document from view and in theNEWENTRY_REQUEST event, I need a document created with the values from the selected document.
Following is code I am using…
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)
%REM
This view has two editable columns: one Text and one Numeric.
The programmatic name of each editable column
is the same as the name of the field whose value it holds,
but the processing for each column is different.
%END REM
REM Define constants for request types
Const QUERY_REQUEST = 1
Const VALIDATE_REQUEST = 2
Const SAVE_REQUEST = 3
Const NEWENTRY_REQUEST = 4
REM On Error Goto Errhandle
REM Define variables
Dim ws As New NotesUIWorkspace
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim caret As String
REM Get the CaretNoteID - exit if it does not point at a document
caret = Source.CaretNoteID
If caret = "0" Then Exit Sub
REM Get the current database and document
Set db = Source.View.Parent
Set doc = db.GetDocumentByID(caret)
Dim value As String
If RequestType = QUERY_REQUEST And ColProgName(0) = "Vendor_Information" Then
Dim luReturn As Variant
luReturn = Evaluate(|@Unique(@DbColumn( ""; @Subset(@DbName;1):@GetProfileField("PortalDBPaths";"KAMPath"); "(TenantSettingsByProjectLease)";1))|, doc)
value = ws.Prompt(PROMPT_OKCANCELLIST,"SELECT","Select a Type","",luReturn)
End If
REM Select the request type
Select Case Requesttype
Case QUERY_REQUEST
If value = "" Then Exit Sub
continue=False
Call doc.ReplaceItemValue(Colprogname(0), value)
Call doc.Save(True, False)
Call ws.ViewRefresh
Case VALIDATE_REQUEST
REM Cause validation error if user tries to exit column with no value
If Fulltrim(Columnvalue(0)) = "" Then
Messagebox "You must enter a value",, "No value in column"
Continue = False
End If
Case SAVE_REQUEST
REM Write the edited column view entries back to the document
For i = 0 To Ubound(Colprogname) Step 1
Call doc.ReplaceItemValue(Colprogname(i), Columnvalue(i))
Next
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
Case NEWENTRY_REQUEST
REM Create document and create “Form” item
REM Write column values to the new document
Set doc = New NotesDocument(db)
Call doc.ReplaceItemValue("Form", "ContractSummary")
For i = 0 To Ubound(Colprogname) Step 1
Call doc.ReplaceItemValue(Colprogname(i), Columnvalue(i))
Next
REM Save(force, createResponse, markRead)
Call doc.Save(True, True, True)
End Select
End Sub