Lotus Domino script snippet Editable Column
Use the InViewEdit (View) sub to update documents by easily editing the column value in the view.
Make sure to check the ‘Editable column’ box for specified field(s).
Easily edit the value in the view without having to edit the document itself.
When opening the document, notice that the value has changed.
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 |
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. REM ColumnNumber is physical column number to edit. REM ColumnValue is passed back if Query & Validation. REM ColumnValue is passed to us to save it back in the document when requesttype is 3 REM We return CONTINUE as TRUE if everything is valid. FALSE if need to abort Const QUERY_REQUEST = 1 Const VALID_REQUEST = 2 Const SAVE_REQUEST = 3 Const NEWENTRY_REQUEST = 4 Const COLUMN_1 = "Veldnaam_1" Const COLUMN_2 = "Veldnaam_2" Const COLUMN_3 = "Veldnaam_3" Const COLUMN_4 = "Veldnaam_4" Const COLUMN_5 = "Veldnaam_5" Const COLUMN_6 = "Veldnaam_6" Const COLUMN_7 = "Veldnaam_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("Veldnaam_1")(0) Continue = True GoTo NOSAVE Case COLUMN_2: ColumnValue = note.GetItemValue("Veldnaam_2")(0) Continue = True GoTo NOSAVE Case COLUMN_3: ColumnValue = note.GetItemValue("Veldnaam_3")(0) Continue = True GoTo NOSAVE Case COLUMN_4: ColumnValue = note.GetItemValue("Veldnaam_4")(0) Continue = True GoTo NOSAVE Case COLUMN_5: ColumnValue = note.GetItemValue("Veldnaam_5")(0) Continue = True GoTo NOSAVE Case COLUMN_6: ColumnValue = note.GetItemValue("Veldnaam_6")(0) Continue = True GoTo NOSAVE Case COLUMN_7: ColumnValue = note.GetItemValue("Veldnaam_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("Veldnaam_1")) Then Call note.replaceitemvalue("Veldnaam_1", ColumnValue(index)) Case COLUMN_2: If (note.hasitem("Veldnaam_2")) Then Call note.replaceitemvalue("Veldnaam_2", ColumnValue(index)) Case COLUMN_3: If (note.hasitem("Veldnaam_3")) Then Call note.replaceitemvalue("Veldnaam_3", ColumnValue(index)) Case COLUMN_4: If (note.hasitem("Veldnaam_4")) Then Call note.replaceitemvalue("Veldnaam_4", ColumnValue(index)) Case COLUMN_5: If (note.hasitem("Veldnaam_5")) Then Call note.replaceitemvalue("Veldnaam_5", ColumnValue(index)) Case COLUMN_6: If (note.hasitem("Veldnaam_6")) Then Call note.replaceitemvalue("Veldnaam_6", ColumnValue(index)) Case COLUMN_7: If (note.hasitem("Veldnaam_7")) Then Call note.replaceitemvalue("Veldnaam_7", ColumnValue(index)) End Select ' ColProgName(index) Next ' ColProgName(index) 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.Veldnaam_1 = ColumnValue(index) Case COLUMN_2: note.Veldnaam_2 = ColumnValue(index) Case COLUMN_3: note.Veldnaam_3 = ColumnValue(index) Case COLUMN_4: note.Veldnaam_4 = ColumnValue(index) Case COLUMN_5: note.Veldnaam_5 = ColumnValue(index) Case COLUMN_6: note.Veldnaam_6 = ColumnValue(index) Case COLUMN_7: note.Veldnaam_7 = ColumnValue(index) End Select ' ColProgName(index) Next ' ColProgName(index) 'saving SAVE: Call note.save(True, True, True) Call ws.viewrefresh() ' No save necessary NOSAVE: End Select End Sub |