Search <Object> forms in the Web Client
The
Search <Object> forms support standard script
hooks, such as
PreSave
,
PostLoad
,
PreSearch
, and
PostSearch
.
During the execution of a search, three custom events are fired:
-
PreSearch
-
PreSearchExecute
-
PostSearch
These events use the base class for the
FcProcFuncSetEventSearch
script hook. This script hook provides the
script with additional context information about the search that is being executed. The
system administrator has the ability to alter the search results.
Option Strict On
Imports System
Imports System.Collections.Generic
Imports System.Data
Class HookScript
Inherits FcProcFuncSetEventHook
Function PostLoad() As Long
MessageList("PostLoad Event")
Return 0
End Function
Function PreSave() As Long
MessageList("PreSave Event")
Return 0
End Function
Function PreSearch() As Long
' Use this script event for any DDL operations with the database, like creating a
' special index, or custom criteria table.
' This event is executed outside of the DB Transaction that the search is
' executed. This event is executed prior to Optiva examining any of the search
' criteria. You may alter the criteria values here as needed.
MessageList("PreSearch Event")
Return 0 ' Return a negative value to cancel the search.
End Function
Function PreSearchExecute() As Long
' This event is executed after Optiva has examined all of the criteria, and has
' generated the search SQL statement, but has not executed that statement yet.
' You may alter this SQL, and Optiva can optionally use the updated SQL.
MessageList("PreSearchExecute Event")
MessageList("Criteria SQL: " & SearchSQL)
SearchSQL &= " Modifying the Search SQL Here."
MessageList("Updated Criteria SQL: " & SearchSQL)
' Return a negative value to cancel the search.
' Return a 1 to tell Optiva to use the new SQL stored in the SearchSQL variable.
Return 0
End Function
Function PostSearch() As Long
' This event is executed after Optiva has populated the search result table,
' but before the search result Views have been populated.
' You can examine the search result table via the ResultTableRead method.
' You can update the contents of the search result table via the
' ResultTableUpdate method.
MessageList("PostSearch Event")
MessageList("Criteria SQL: " & SearchSQL)
Dim Results As DataTable = ResultTableRead("ZZFORMULASEARCHHOOKREAD1", Nothing,
Nothing)
If Results Is Nothing Then
MessageList("No result table returned from ResultTableRead")
Else
MessageList("ResultTableRead returned " & Results.Rows.Count.ToString() & " rows.")
End If
Dim rc As Integer = ResultTableUpdate("ZZFORMULASEARCHHOOKADD1", New List(Of String)
From {"9999341"}, Nothing)
MessageList("Return from ResultTableUpdate: " & rc.ToString())
Dim ResultConfirm As DataTable = ResultTableRead("ZZFORMULASEARCHHOOKREAD1",
Nothing, Nothing)
If ResultConfirm Is Nothing Then
MessageList("No result confirmation table returned from ResultTableRead")
Else
MessageList("ResultTableRead returned " & ResultConfirm.Rows.Count.
ToString() & "confirmation rows.")
Return 1 ' Tells Optiva that the script has modified the number of rows in the search result tab
End If
Return 0
End Function
End Class
In the example above,
ZZFORMULASEARCHHOOKREAD1
is the name of the
FsQuery
entry that you created.