Lotus Domino script snippet Editable Column (Inviewedit)
Use the Inviewedit code to update document field values directly from the Lotus Notes view, without opening the document itself.
To accomplish this, do the following:
- Create a form with some fields (FieldName_1 -> FieldName_7 in this example)
- In the Domino Designer Client, create/open the view that you want to make editable.
- For each column that you want to make editable within this view, set these properties:
Add the following code to the Inviewedit sub of the view:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant) %REM RequestType is 1 for Query, 2 for Validation, & 3 for Saving Edit. ColumnNumber is physical column number to edit. ColumnValue is passed back if Query & Validation. ColumnValue is passed to us to save it back in the document when requesttype is 3 We return CONTINUE as TRUE if everything is valid. FALSE if need to abort %END REM Const QUERY_REQUEST = 1 Const VALID_REQUEST = 2 Const SAVE_REQUEST = 3 Const NEWENTRY_REQUEST = 4 Const COLUMN_1 = "FieldName_1" Const COLUMN_2 = "FieldName_2" Const COLUMN_3 = "FieldName_3" Const COLUMN_4 = "FieldName_4" Const COLUMN_5 = "FieldName_5" Const COLUMN_6 = "FieldName_6" Const COLUMN_7 = "FieldName_7" Dim ws As New notesuiworkspace Dim note As NotesDocument Dim item As NotesItem Dim db As NotesDatabase Dim index As Integer Continue = False Set db = ws.currentdatabase.database If (RequestType <> VALID_REQUEST) And (RequestType <> NEWENTRY_REQUEST) Then If Not (source.Caretnoteid) = "0" Then Set note = db.GetDocumentByID(source.caretnoteid) Else Set note = New Notesdocument(db) End If If (note Is Nothing) Then Exit Sub '// Responses can't be modified in the view If note.IsResponse Then Msgbox "To edit a response document, you must open the document." Exit Sub End If End If Select Case RequestType Case QUERY_REQUEST: Select Case ColProgName(0) Case COLUMN_1: ColumnValue = note.GetItemValue("FieldName_1")(0) Continue = True Goto NOSAVE Case COLUMN_2: ColumnValue = note.GetItemValue("FieldName_2")(0) Continue = True Goto NOSAVE Case COLUMN_3: ColumnValue = note.GetItemValue("FieldName_3")(0) Continue = True Goto NOSAVE Case COLUMN_4: ColumnValue = note.GetItemValue("FieldName_4")(0) Continue = True Goto NOSAVE Case COLUMN_5: ColumnValue = note.GetItemValue("FieldName_5")(0) Continue = True Goto NOSAVE Case COLUMN_6: ColumnValue = note.GetItemValue("FieldName_6")(0) Continue = True Goto NOSAVE Case COLUMN_7: ColumnValue = note.GetItemValue("FieldName_7")(0) Continue = True Goto NOSAVE End Select Case VALID_REQUEST: Select Case ColProgName(0) Case COLUMN_1: continue = True Case COLUMN_2: continue = True Case COLUMN_3: continue = True Case COLUMN_4: continue = True Case COLUMN_5: continue = True Case COLUMN_6: continue = True Case COLUMN_7: continue = True End Select Case SAVE_REQUEST: For index = 0 To Ubound(ColProgName) Select Case ColProgName(index) Case COLUMN_1: If (note.hasitem("FieldName_1")) Then Call note.replaceitemvalue("FieldName_1", ColumnValue(index)) Case COLUMN_2: If (note.hasitem("FieldName_2")) Then Call note.replaceitemvalue("FieldName_2", ColumnValue(index)) Case COLUMN_3: If (note.hasitem("FieldName_3")) Then Call note.replaceitemvalue("FieldName_3", ColumnValue(index)) Case COLUMN_4: If (note.hasitem("FieldName_4")) Then Call note.replaceitemvalue("FieldName_4", ColumnValue(index)) Case COLUMN_5: If (note.hasitem("FieldName_5")) Then Call note.replaceitemvalue("FieldName_5", ColumnValue(index)) Case COLUMN_6: If (note.hasitem("FieldName_6")) Then Call note.replaceitemvalue("FieldName_6", ColumnValue(index)) Case COLUMN_7: If (note.hasitem("FieldName_7")) Then Call note.replaceitemvalue("FieldName_7", ColumnValue(index)) End Select Next Goto SAVE Case NEWENTRY_REQUEST: ' Column Value is an array of items that you edited in place in the view For index = 0 To Ubound(ColProgName) Select Case ColProgName(index) Case COLUMN_1: note.FieldName_1 = ColumnValue(index) Case COLUMN_2: note.FieldName_2 = ColumnValue(index) Case COLUMN_3: note.FieldName_3 = ColumnValue(index) Case COLUMN_4: note.FieldName_4 = ColumnValue(index) Case COLUMN_5: note.FieldName_5 = ColumnValue(index) Case COLUMN_6: note.FieldName_6 = ColumnValue(index) Case COLUMN_7: note.FieldName_7 = ColumnValue(index) End Select Next SAVE: Call note.save(True, True, True) Call ws.viewrefresh() NOSAVE: End Select End Sub |