FindDocuments method
Searches for documents in the Main area of the current vault.
Syntax
FindDocuments([WildCard As String], [DocumentTypeNames As Variant], [Criteria As Variant], OrSearch As Boolean) _ As IASDocuments
Name | Description |
---|---|
WildCard |
Optional string that represents a file system wildcard pattern. If omitted, the scope of file names will include all documents (*.*). |
DocumentTypeNames |
Optional variant array of document type names to which to restrict the search result. If omitted, the scope of document types will include all document types. |
Criteria |
Optional variant array of property filter criteria. |
OrSearch |
Optional Boolean that if set to True specifies a Boolean OR search be performed. The default is False. |
Return Value
Returns a collection of About the Document object objects matching the specified parameters.
Remarks
The Criteria parameter can be specified as a single criterion array or as an array of criterion arrays. Each criterion array contains a property name, operator, and an optional value similar to the Find command in PowerUserMeridian. For example, Custom.ProjectNr, equals, 2134, where equals is the operator.
The search operators that are supported are those in the IC_OPERATOR constants enumeration. The following table lists the supported operators and the abbreviations, symbols, and constants that may be used:
Operator | Abbreviation | Symbol |
Constant |
---|---|---|---|
contains, in |
C |
* |
IC_OP_CONTAINS |
date equals |
IC_OP_DATE_EQUALS |
||
date not equal |
IC_OP_DATE_NOT_EQUAL |
||
date less |
IC_OP_DATE_LESS |
||
date less or equal |
IC_OP_DATE_LESS_EQUAL |
||
date more |
IC_OP_DATE_MORE |
||
date more or equal |
IC_OP_DATE_MORE_EQUAL |
||
doswildcard |
IC_OP_DOSWILDCARD |
||
empty |
EM |
() |
IC_OP_EMPTY |
equals, equal |
E |
EQ = |
IC_OP_EQUALS |
less |
L |
< |
IC_OP_LESS |
less equal |
LE |
<= |
IC_OP_LESS_EQUAL |
like |
LI |
% |
IC_OP_LIKE |
more |
M |
> |
IC_OP_MORE |
more equal |
ME |
>= |
IC_OP_MORE_EQUAL |
not contains |
NC, NOT IN |
|
IC_OP_NOT_CONTAINS |
not empty |
NEM |
IC_OP_NOT_EMPTY |
|
not equal |
NEQ, NE |
<> |
IC_OP_NOT_EQUAL |
not like |
NLI, NL |
IC_OP_NOT_LIKE |
|
not starts with |
NSW |
IC_OP_NOT_STARTWITH |
|
starts with |
SW |
IC_OP_STARTWITH |
- The expression Vault.FindDocuments(<Criteria>).Count will return the number of documents that are found.
- The expression Vault.FindDocuments(<Criteria>).Properties will return 25 values for each document found without the property names, in no particular order.
- The expression Vault.FindDocuments(<Criteria>).Document(Document.ID).FileName will return the file name of a document if it matches the specified parameters.
- If you want to find a document with a specific ID, use the Vault.GetDocument method described in GetDocument method instead. Executing an expression such as Vault.FindDocuments.Document(ID) will cause the server to first create a collection of all documents in the vault and then search within that collection for the document with the specified ID. Such an operation can result in a large load on the server and take an excessive amount of time compared to using the Vault.GetDocument method.
- For best results when searching on date (day without time) values, use the operators with names that begin with IC_OP_DATE. For date with time (moment) searches, use the other operators.
- This method can return different results if it is called within the Document_AfterNewDocument event depending on whether Hypertrieve 3 or Hypertrieve 5 is used as the database engine of the vault. If the new document name matches the WildCard parameter, the collection of document IDs returned by a Hypertrieve 5 vault will contain the new document. A Hypertrieve 3 vault will not contain the new document. To make your script compatible with both vault types, it should filter the ID of the new document out of the search results. Similarly, if no results are expected (such as testing for a unique document name) but one document is returned, test whether it is the new document and proceed accordingly.
Example
The following example demonstrates use of the FindDocuments method to display the results of a search executed with the specified parameters.
Sub SearchCount_Execute(Batch) Dim StrMask StrMask = "*1*.*" Dim MultipleDocTypes MultipleDocTypes = Array("My_Doc_Type", "Hybrid_Doc_Type") Dim MultipleCriteria MultipleCriteria = Array(_ Array("Custom.CI", IC_OP_MORE, 200),_ Array("Custom.CI", IC_OP_LESS, 300),_ Array("Custom.CS", IC_OP_CONTAINS, "o"),_ Array("Custom.CStr", IC_OP_CONTAINS, "iv"),_ Array("Custom.LOL", IC_OP_EQUALS, "a-z"),_ Array("AMVersionablePropertySet._VERSIONNUMBER", IC_OP_LESS, 2),_ Array("Custom.CDT", IC_OP_LESS, (DateSerial(1983,07,12))),_ Array("NewPS.CB", IC_OP_EQUALS, False)) Dim bool bool = True Dim Str Str = "" Dim Document For Each Document In Vault.FindDocuments(StrMask, MultipleDocTypes, _ MultipleCriteria, bool) str = str &_ " FileName - > " & Document.FileName & vbCrLf &_ " Document.DocumentType.DisplayName - > " & _ Document.DocumentType.DisplayName & vbCrLf &_ " Custom.CI - > " & Document.CI & vbCrLf &_ " Custom.CS - > " & Document.CS & vbCrLf &_ " Custom.CStr - > " & Document.CStr & vbCrLf &_ " Custom.CDT - > " & Document.CDT & vbCrLf &_ " NewPS.CB - > " & Document.NewPS_CB & vbCrLf &_ " NewPS.CM - > " & Document.NewPS_CM & vbCrLf &_ " Custom.LOL - > " & Document.Custom_LOL & vbCrLf &_ " Revision - > " & Document.Revision & vbCrLf & vbCrLf Next WinMsgBox "Total number of documents found is " &_ Vault.FindDocuments(StrMask, MultipleDocTypes, MultipleCriteria, bool).Count & _ vbCrLf & vbCrLf & Str End Sub