lotusscriptlotus

How to test if a field exist in a ui document or hide a Notes error-message about it


I write an agent who test for every fields in a list if it is empty or not. Fields can be every type, including RichText. Rich text fields can contain text or attachement. The agent must be run on UIDocument because user is not allowed to save if a required field is empty.

We have an existing agent but it return sometimes (5 or 6 times by day) errors "4602 : L'opération DOM Parser a échoué" (I think it should be something like "operation DOM Parser failed" in english) in this line :

Call DXLExporter.process

I find on Internet that it's a server problem I don't have the hand on it. I find something interresting to replace existing agent :

' source is the NotesUIDocument, send to the agent in parameter
' champSource is a string : the name of the field

On Error GoTo ErrorHandler

Call source.GoToField(ChampSource)
Call source.SelectAll
Call source.DeselectAll

Exit Function
ErrorHandler:
    Select Case Err
        Case 4407 ' empty field
            Print "champ vide : " & ChampSource
        Case 4412 ' non-existent field
            Print "champ non trouvé : " & ChampSource
        Case Else
                Print LSI_Info(2) & " - " & Error & " - " & Err & " - " & Erl
        End Select
    Exit Function

And it works, the "source.DeselectAll" generate an error 4407 if the field is empty, and no error if it contains anything.

The problem is that it's a form with fields "hidden when". When one of this field is tested, if it is hidden I got a Notes pop-up "Impossible de localiser ce champ" (that should be something like "impossible to locate this field" in english) in this line :

Call source.GoToField(ChampSource)

And only after this pop-up the script goes to the ErrorHandler.

I try to add a condition before :

If source.Document.HasItem(ChampSource) Then
    Call source.GoToField(ChampSource)
    Call source.SelectAll
    Call source.DeselectAll
End If

But the item exist in the document despite the field doesn't exist in the ui document.

I'm looking for a solution to hide the Notes pop-up and let my ErrorHandler make his job or to test if the field exist in the ui document.

Thanks in advance for the answer.

PS : sorry for my poor english, I'm french.


Solution

  • Regarding the dom parser error. I have the same error on my server. And I have found two solutions that work (most of the times).

    1. Retry several times. That is if error 4602 then try again. Set max retries to 10-20 times. I still see errors with this approach, but not as often as before.
    2. Don't validate. Set InputValidationOption on DOM parser to VALIDATE_NEVER.

    https://www.ibm.com/support/knowledgecenter/SSVRGU_8.5.3/com.ibm.designer.domino.main.doc/H_INPUTVALIDATIONOPTION_PROPERTY_IMPORTER.html