Skip to main content

Allow blank date fields using SBL Validation Script


QAID # 400 Published

Question / Problem:

How can I allow date fields to be blank in Validation?

Answer / Solution:

Kofax Capture does not by default allow for blank Index Fields of data type "Date." However, you can associate an Index Field with a VARCHAR field type and modify the Validation Script or create your own Field Type Macro to perform this. Below is an example of a Field Type Macro that allows for blank date fields. Please note that in the example below, the field Type name is "Date" and its data type is "VARCHAR".

REM ========================================================================
REM Field Macro Name: Date
REM ------------------------------------------------------------------------
            ' Uncomment the global definition below if the
            ' script is to have read-only access to the
            ' index field's Confidence Level (CL).
'Global KfxCL_KFX_Date As String
            ' Index field value.
Global Kfx_KFX_Date As String
            '===== SQL_DATE Procedures
' Return codes are defined by the document class customization script.
            '----- _KFX_Date default value: todays's date
Function Pre_KFX_Date() As Integer
    On Error GoTo Failure
    'With Capture 3.0, default values are set in the Administration module.
    'Enable and modify the following line to override the Administration-set default
    'If (Kfx_KFX_Date = "") Then Kfx_KFX_Date = Format$(Now, "ddddd")
    Pre_KFX_Date = NoError
    Exit Function
    Pre_KFX_Date = FatalError
    Exit Function
End Function
            '----- _KFX_Date validation: checks for valid
            '----- date. Format of validated string must
            '----- match WIN.INI sShortDate format setting.
Function Post_KFX_Date( EnteredValue As String ) As Integer
    On Error GoTo Failure
    EnteredValue = Trim(EnteredValue)
    if enteredvalue = "" then '    *** This will check to see if the field is blank
        kfx_KFX_Date = "" '                *** This will Assign the value to the database
        Post_KFX_Date = NoError '    *** This will tell the script that there is no error
        exit function '                          *** This will exit the function so the rest of the code doesn't run.
    end if
    If Not IsDate(EnteredValue) Then GoTo Failure
    Kfx_KFX_Date = CStr( DateValue(EnteredValue) )
    Post_KFX_Date = NoError
    Exit Function
    Post_KFX_Date = ValidationError
    Exit Function
End Function
            '----- _KFX_Date format
Function Fmt_KFX_Date() As String
    'The On Error is here to trap unexpected exceptions, however this function
    'does not return a status.
    On Error GoTo Failure
    If ( Kfx_KFX_Date = "" ) Then GoTo Failure
    Fmt_KFX_Date = Format( DateValue(Kfx_KFX_Date) )
    Exit Function
    Fmt_KFX_Date = Kfx_KFX_Date
End Function

Applies to:

Product Version
  • Was this article helpful?