Read and Process Index Data |
Scroll |
The TheDocument class provides access to its TheIndexData member through the IndexData property. This TheIndexData object contains category-dependent meta-data for the object (e.g. document number, title, category information, version, author, invoice number, due date etc.). This data is stored as a map of {string fieldName, object value} pairs. It is possible to get and set values by their field name and to iterate through field names, values or both. The Step By Step guide and the examples below illustrate how to read and iterate index data. Please see "Edit and Save Index Data" to learn how to modify and save index data values.
1 |
Connect to the Thereforeā¢ server (see "Server - Connect and Disconnect" for Details) |
2 |
Declare and initialize a new TheDocument instance. |
3 |
Retrieve the document from the server. |
4 |
Get the document's IndexData. |
5 |
Iterate and print the index data. 5A. Iterate {string fieldname, object value} pairs. or 5B. Iterate field names only. or 5C. Iterate values only. |
Requirements and Assumptions: Document number 42 exists in your Thereforeā¢ system. If these assumptions do not apply to your system or configuration please replace them with appropriate values when copying the code samples below. Visual Basic Imports Therefore.API '...
' 1. Connect to the Thereforeā¢ server Dim server As New TheServer server.Connect(TheClientType.CustomApplication)
' 2. Declare and initialize a new Thereforeā¢ document Dim doc As New TheDocument
' 3. Retrieve the document from the server to the inbox Dim docNo As Integer = 42 doc.Retrieve(docNo, "", server)
' 4. Get the document's index data Dim indexData As TheIndexData = doc.IndexData
' 5A. Iterate index data pairs in a for-each loop Dim pair As ThePair For Each pair In indexData Console.WriteLine(pair.ToString()) Next
' 5B. Iterate index data field names only ' Dim fieldName As String ' For Each fieldName In indexData.FieldNames ' Console.WriteLine(fieldName) ' Next
' 5C. Iterate index data field names only ' Dim value As Object ' For Each value In indexData.Values ' Console.WriteLine(value.ToString()) ' Next C# using Therefore.API; //...
// 1. Connect to the Thereforeā¢ server TheServer server = new TheServer(); server.Connect(TheClientType.CustomApplication);
// 2. Declare and initialize a new Thereforeā¢ document TheDocument doc = new TheDocument();
// 3. Retrieve the document from the server to the inbox int docNo = 42; doc.Retrieve(docNo, "", server);
// 4. Get the document's index data TheIndexData indexData = doc.IndexData;
// 5A. Iterate index data pairs in a for-each loop foreach (ThePair pair in indexData) Console.WriteLine(pair.ToString());
// 5B. Iterate index data field names only // foreach (string fieldName in indexData.FieldNames) // Console.WriteLine(fieldName);
// 5C. Iterate index data field names only // foreach (object value in indexData.Values) // Console.WriteLine(value.ToString()); |
Using the Default Thereforeā¢ Inbox If the empty string ("") is passed as the second (strInbox) parameter of the Retrieve method, the default Thereforeā¢ inbox will be used for retrieval. |