Edit and Save 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 modify index data values and how to save the changes made. Please see "Read and Process Index Data" to learn how to read, process and iterate TheIndexData.
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 |
Modify index data values. |
6 |
Save changes to the Thereforeā¢ server. |
Requirements and Assumptions: Document number 42 exists in your Thereforeā¢ system. Index Data contains the money (decimal) fields "AmountNet" and "AmountVAT". 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
' 5. Modify index data values indexData("AmountNet") = 500.00 indexData("AmountVAT") = 550.00
' 6. Save the changes to the server indexData.SaveChanges(server) 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;
// 5. Modify index data values indexData["AmountNet"] = 500.00; indexData["AmountVAT"] = 550.00;
// 6. Save the changes to the server indexData.SaveChanges(server);
|
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. |