Inview edit validation problem

Hi Everybody,A document with a text field x has a value 8.

This is selected in a view. There is validation in the the script to trap invalid values.

When view column is edited in notes and the value is modified to 8&. The Invalid value message is shown desired but thereafter notes

throws an error message “Error validating column value”.

Is there any solution to this problem ? I want to avoid this prompt message, but display my invalid message while validating

Thanks

Ankit


The inview edit script is as below

Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)

Const QUERY_REQUEST = 1

Const VALIDATE_REQUEST = 2

Const SAVE_REQUEST = 3

Const NEWENTRY_REQUEST = 4

REM Define variables

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)

REM Select the request type

Select Case Requesttype

Case QUERY_REQUEST

REM Reserved - do not use in Release 6.0

Case VALIDATE_REQUEST

Msgbox "Columnvalue(0) "&Columnvalue(0)

REM Cause validation error if user tries to exit column with no value

If Instr(Columnvalue(0)," ") Then

Continue = False

Msgbox “with space”

End If

If Instr(Columnvalue(0),“&”) Then

Continue = False

Msgbox “with&”

Exit Sub

End If

Case SAVE_REQUEST

REM Write the edited column view entries back to the document

For i = 0 To Ubound(Colprogname)

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”, “Test”)

For i = 0 To Ubound(Colprogname)

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

Next

REM Save(force, createResponse, markRead)

Call doc.Save(True, True, True)

End Select

End Sub

Subject: Inview edit validation problem

Get the error number for that error (using a Messagebox or a Print statement) and than write an error handler specifically for this error number that does nothing.

Subject: RE: Inview edit validation problem

The error that is shown is a message box with title ‘IBM Lotus Notes’ and message as ‘Error validating column value’. I am not able to find the error number. This occurs due to the statement ‘continue = False’ in validation portion. If this statement isn’t included, then the save event is automatically triggered and the document is saved with invalid entry which shouldn’t occur. Need your help.

Subject: RE: Inview edit validation problem

The error text wont help you.

Use the Err function to return the error number. Once you know this error number, you can write an On Error statement specifically for this error.

Subject: RE: Inview edit validation problem

Tried debugging the code using the Err function, the error message is displayed after the end sub(last statement) of the inview edit event and so doesnt displays the error number, it comes out of all the select cases, goes to the error handler (next statement) just shows error number 0, then end sub and then shows the error message which i want to avoid.

The help menu says ‘Set this parameter(continue) to False to stop processing and generate an error message’


The inview edit script is as below

Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)

Const QUERY_REQUEST = 1

Const VALIDATE_REQUEST = 2

Const SAVE_REQUEST = 3

Const NEWENTRY_REQUEST = 4

REM Define variables

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)

REM Select the request type

Select Case Requesttype

Case QUERY_REQUEST

REM Reserved - do not use in Release 6.0

exit sub

Case VALIDATE_REQUEST

Msgbox "Columnvalue(0) "&Columnvalue(0)

REM Cause validation error if user tries to exit column with no value

If Instr(Columnvalue(0)," ") Then

Continue = False

Msgbox “with space”

End If

If Instr(Columnvalue(0),“&”) Then

Continue = False

Msgbox “with&”

On Error GoTo Errhandle

'doesnt goes to errhandle

'exit sub

End If

Case SAVE_REQUEST

REM Write the edited column view entries back to the document

For i = 0 To Ubound(Colprogname)

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

Next

REM Save(force, createResponse, markRead)

Call doc.Save(True, True, True)

exit sub

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”, “Test”)

For i = 0 To Ubound(Colprogname)

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

Next

REM Save(force, createResponse, markRead)

Call doc.Save(True, True, True)

exit sub

End Select

Errhandle:

MessageBox “Error” & Str(Err) & ": " & Error$

'show error 0

Exit Sub

End Sub

'displays error message after control to this statement

Subject: RE: Inview edit validation problem

Without checking any detail yet, your code is currently missing an Exit Sub after the End Select. Right now, your error handler is always executed, even if no error occurs.

Subject: RE: Inview edit validation problem

I have corrected that, but still it doesnt works. The previous error message still persists


Sub Inviewedit(Source As Notesuiview, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)

Dim ws As New NotesUIWorkspace

Dim uidoc As notesuidocument

Dim edoc As notesdocument	

Set uidoc = ws.CurrentDocument



'Set edoc=uidoc.document

Const QUERY_REQUEST = 1

Const VALIDATE_REQUEST = 2

Const SAVE_REQUEST = 3

Const NEWENTRY_REQUEST = 4

Dim db As NotesDatabase

Dim doc As NotesDocument

Dim caret As String

'Dim txt1,txt2,txt3 As String

'Dim chk As Integer

Dim item As NotesItem

caret = Source.CaretNoteID

If caret = "0" Then Exit Sub

Set db = Source.View.Parent

Set doc = db.GetDocumentByID(caret)

'On Error Goto Errhandle

Select Case Requesttype

	

Case QUERY_REQUEST

REM Reserved - do not use in Release 6.0

Case VALIDATE_REQUEST

Msgbox "Columnvalue(0) "&Columnvalue(0)

REM Cause validation error if user tries to exit column with no value

If Instr(Columnvalue(0)," ") Then

Continue = False

Msgbox “with space”

End If

If Instr(Columnvalue(0),“&”) Then

Continue = False

Msgbox “with&”

			On Error Goto Errhandle

'it doesnt goes to errhandle

		End If

	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", "Main")

	

	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 Else

	

End Select

Exit Sub

Errhandle:

’ Use the Err function to return the error number and

’ the Error$ function to return the error message.

Messagebox "Error" & Str(Err) & ": " & Error$

End Sub

Subject: work around

good old buggy notes!I am having the same problem.

This work around from Toby may help.

(disadvantage: user looses the focus and his entries)

Have a look into

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/1af83491ef694de385256d88006330cd?OpenDocument

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/c4efbd3607e7541985256d8800630d9a?OpenDocument

Thank you, Toby!