FindAgent supports saved restrictions and also handles some behind-the-scenes translation related to reporter criteria that the archive agent does not need to worry about.
The example below shows the use of the SaveRestrictions method exposed through the FindAgent.
CS
FindAgent instance, which contains the method that we use. Once the initialization is done, we declare the variable that we would need to pass to the different methods we use.
storageType
The storage type specification of the restriction, which could be “Criteria” or “Reporter” or any possible extension.providerName
This is the name of the archive provider which is intended to use the restriction.storageKey
This is to be interpreted by the restriction storage provider when it fetches the criteria for the search.staticColumns
This is an array of restrictions that are to be excluded from theCriteriaArchiveRows part of the result.
In the Find dialog that corresponds to the “static fields”, this variable is used to avoid duplication in the Match also criteria list. In place, this variable is used it could be stated as null, which indicates that all restrictions should be included in the criteria list.
For example, if you have a criteria such as person/firstname=“John” then all matches on this field will contain the same value “John” and the column can be excluded from the result making more room for the useful information.
handledColumns
CS
CriteriaArchiveRows part of the result. In the Find dialog, that corresponds to the “static fields” this variable is used to avoid duplication in the “Match also” criteria list. In places, this variable is used it could be stated as null which indicates that all restrictions should be included in the criteria list.
When retrieving the list of columns for the variable we have made use of the GetAvailableRestrictionColumns method, which requires the storageType and providerName as the input parameters. It returns a list of column names corresponding to the available restrictions for the passed in providerName and storageType.
CS
CS
Dictionary class located in the System.Collection.Generic namespace, which will store the restrictions as a key-value pair. The key is of string type and the values are of ArchiveRestrictionInfo type, which is a class that carries information such as contact_id = 2 which could be used in a query of an ArchiveProvider.
Once this is done, we may create and assign different restrictions. The example shows how to assign restrictions to multiple types of data as well as user-defined fields.
When executing the code for a user, an error might occur based on the state of their database since they may not have some or all of the user-defined fields shown in the example. In such a case, the code will be executable once the user-defined fields have been commented out or removed.
CS
SaveRestriction method exposed in the IFindAgent interface, the restriction will be saved so that it could later be used as a search criterion including dynamic search and find statements. The method requires the parameters:
- storageType
- providerName
- storageKey
- an array of ArchiveRestrictionInfo
CollectionsOps class exposed in the SuperOffice.Util class to convert between various collections of data. In this case, from Dictionary type to an array of ArchiveRestrictionInfo type.