auf LDD gibt es ein Redbook zu R6 Entwicklung (PDF = 13 MByte), ab Seite 454
darin steht wie man zB aus einer View heraus Docs erzeugen UND Felder editieren kann:
Create document from view
This feature lets the users create documents directly from the view, without
opening a new window. The users fill the fields in through the view columns. In
this context, the columns appear in edit mode. To set this feature, do the
following:
1. Select the “Create new documents at view level” option in the View’s
properties box.
2. Select “Editable column” in the Column’s properties box for the columns
where you want the user to enter data.
3. Add code to the view’s InViewEdit event to handle the document creation and
validation entries. You can program this event only with LotusScript.
Example 12-5 shows a sample of programming the view’s InViewEdit event to
create a document. In this sample database, there is a form with two fields:
Firstname and LastName. In the view we just allow the user to fill the Firstname
field.
Example 12-5 Create a document from a view
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As
Variant, Columnvalue As Variant, Continue As Variant)
Const QUERY_REQUEST = 1 ' values for RequestType
Const VALIDATE_REQUEST = 2
Const SAVE_REQUEST = 3
Const NEWENTRY_REQUEST = 4
' Editable column
Const COLUMN_FEATURE = "Firstname" 'programmatic name of column
Const FIELD_FEATURE = "Firstname" 'corresponding field name
Dim ws As New NotesUIWorkspace
Dim note As NotesDocument
Dim db As NotesDatabase
Set db = ws.CurrentDatabase.Database
If RequestType = NEWENTRY_REQUEST Then
'Create a new document
Set note = db.CreateDocument()
note.Form = "frmPersons"
' Column Value is an array of items that you edited in place in the
view
Call note.ReplaceItemValue (FIELD_FEATURE, ColumnValue(0))
Call note.Save(True, True, True)
End If
End Sub
Explanation
The InViewEdit event runs several times, depending on the request that is being
performed.
Query
This is when the user enters an editable view column entry.
Validate
This is when the user exits an editable view column entry.
Save
This is after validation of one or more view column entries in an existing
document.
In the view, use Ctrl-Click here to add a new document in the bottom of the view
to create a document.
An editable column appears in which to enter data. Fill this in and press Enter, or
click outside of the editable field to finalize the procedure.
A new document is created in the database; see Figure 12-92 on page 459.
Editing a document in a view
You can enable Notes users to edit fields of an existing document directly in a
view. The big advantage of this feature is that the document itself does not need
to be opened—editing takes place directly in the view. This is especially
beneficial for documents where users make only minor changes to few fields and
therefore can avoid opening the document in a separate window.
For in-view editing, there is a new event for a view, called InViewEdit, and the
developers have to enable the column to have this feature, “Editable column”. To
enable a view for this option, follow these steps:
1. Select “Editable column” in the Column’s properties box for the columns
where you want the user to enter data.
2. Add code to the view’s InViewEdit event to handle the document creation and
validation entries. You code this event only with LotusScript.
In this new event, we have to add some code that will make sure that the update
happens, and that validation takes place. Example 12-6 on page 457 shows an
Chapter 12. New features in Domino 6 457
InViewEdit LotusScript that enables InViewEdit to take place, accept all user
inputs, and update the document.
Example 12-6 Editing a document in a view
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As
Variant, Columnvalue As Variant, Continue As Variant)
Const QUERY_REQUEST = 1 ' values for RequestType
Const VALIDATE_REQUEST = 2
Const SAVE_REQUEST = 3
Const NEWENTRY_REQUEST = 4
' Editable column
Const COLUMN_FEATURE = "Firstname" 'programmatic name of column
Const FIELD_FEATURE = "Firstname" 'corresponding field name
Dim ws As New NotesUIWorkspace
Dim note As NotesDocument
Dim db As NotesDatabase
Set db = ws.CurrentDatabase.Database
Set note = db.GetDocumentByID(Source.CaretNoteID)
If (note Is Nothing) Then Exit Sub
If (RequestType = QUERY_REQUEST) Then
If(note.HasItem(FIELD_FEATURE)) Then
'Get the current (original) value to put in Edit box
Columnvalue(0) = note.GetItemValue(FIELD_FEATURE)
Else
'This doc does not contain the required field;
'ignore it
Continue = False
End If
Elseif (RequestType = VALIDATE_REQUEST) Then
'Accept any user input
Continue = True
Elseif (RequestType = SAVE_REQUEST) Then
Call note.ReplaceItemValue (FIELD_FEATURE, ColumnValue(0))
Call note.Save(True, True, True)
End If
End Sub
Tip: CaretNoteID is a new property with Domino 6 that is the Note ID of the
currently highlighted (that is, at the caret location) document in a view.
Explanation
The InViewEdit event runs several times, depending on the request that is being
performed:
Query
This is when the user enters an editable view column entry.
Validate
This is when the user exits an editable view column entry.
Save
This is after validation of one or more view column entries in an existing
document.
1. Before we edit the document, no events are influenced.
2. We click the document and column value we want to edit. This request is a
Query. This request then checks whether the marked document has the field
to be edited. If so, it sets a value of the field to a constant. If not, it exits the
sub.
3. Then, the next request is Validate, which validates the content. We have set it
to accept all inputs.
4. The next request is the Save request, which actually updates the document
by replacing the current value in the field with the new value and saves it.