Search code examples
lotus-noteslotus-dominolotus

Disable edit using querymodechange and sort by form field status


I have created a global variable name parameter. I create this parameter to disable edit mode. I have a status field differentiate by "Active", "Inactive", and "Draft".

Sub Querymodechange(Source As Notesuidocument, Continue As Variant)
    Dim session As New NotesSession     
    Dim db As NotesDatabase
    Dim doc  As NotesDocument
    Dim view As NotesView
    Continue = False

    Set db = session.CurrentDatabase
    Set view = db.GetView("(Parameter)")    

    Set doc = view.GetDocumentByKey("UnderInspection", True)
    If doc Is Nothing Then
        Msgbox "Parameter not found"
        Exit Sub
    End If

    If doc.PValue(0)="1" Then
        Msgbox "Under Inspection! "
        Exit Sub
    End If
    Continue = True
End Sub

As an above code, I will set parameter for form using Querymodechange. If its true, it will continue to false, else it continue to true.

My question is, how can I set querymodechange for status field name "Active" and "Inactive"? E.g when the status of the document is "Active" or "Inactive", it will use this querymodechange as it will disable edit mode. But for "Draft" status, you can edit. Any help will be appreciated. Thanks!


Solution

  • If source.Document.GetItemValue("Status")(0)<>"Draft" Then
         ...
         Exit Sub
    End If