Friday, December 30, 2011

Edit document via its view column entries

It is simple and a very useful when allow user to edit document by caret id of current document through view entries. There is no need opening document in edit mode.

Setp 1:

First Select the columns that will display the editable fields.

Setp 2:

Then choose the design of column properties box and check “Editable column” on the Info tab of the column properties box.

Setp 3:

Goto Inviewedit event in the Programmer’s pane and then type the following coding.

Coding:

Declare and Define constants for request types

Const QUERY_REQUEST = 1 ‘Declare constant for requesting the query to view when user enter the editable column

Const VALIDATE_REQUEST = 2 ‘Validate the current field is editable or not

Const SAVE_REQUEST = 3 ‘Update the editaed values after validation on existing document

Const NEWENTRY_REQUEST = 4 ‘Add enries to new document

‘Declare the neccesscery variables

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim caret As String ‘Variable for getting carret id of currently pointing document

caret = Source.CaretNoteID ‘Get the CaretNoteID

If caret = “0″ Then Exit Sub ‘ exit if it does not point at document

Set db = Source.View.Parent

Set doc = db.GetDocumentByID(caret) ‘ Get the current database and document

Select Case Requesttype ‘Here select the type of request

Case VALIDATE_REQUEST ‘Validate when user tries to save document 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 ‘Check the save mode

For i = 0 To Ubound(Colprogname) Step 1

Call doc.ReplaceItemValue(Colprogname(i), Columnvalue(i))

Next

Call doc.Save(True, True, True)

3 comments:

  1. very good
    one mistake: Add code line: End Select
    before Call doc.save ....

    ReplyDelete