Click or drag to resize

IIQAPIUpdateDocument Method

Post changes to an existing IQDocument object into the ImageQuest system.

Namespace:  Informa.ImageQuest.API.Library
Assembly:  Informa.ImageQuest.API.Library (in Informa.ImageQuest.API.Library.dll) Version: 14.3.0.0
Syntax
void UpdateDocument(
	string token,
	ref IQDocument document
)

Parameters

token
Type: SystemString
User Authentication Token from a previous Login(String, String, String) or SystemLogin(String) call.
document
Type: Informa.ImageQuest.API.LibraryIQDocument
Existing ImageQuest document with changes to be saved.
Remarks

This method updates the index metadata associated with an existing document in ImageQuest. The API consumer may edit any of the existing attributes on a document, or set new attribute values. It is not possible to remove an attribute that is already set on the document.

An API consumer is permitted to change the value of the DocumentType attribute to a new value, as long as that new value is another legal document type in the current cabinet. The index metadata for the document must comply with any constraints, such as required attributes and user permissions, associated with the new document type. Any existing attribute values that are not associated with the new document type will remain present, but no longer be visible to the client applications. These values continue to be visible and editable to API consumer applications.

When updating a document, only attributes with changes, or attributes that have been added to the document since retrieval, will be saved into the ImageQuest system. In particular, is is generally safe for multiple client applications to post changes to the same document as long as those changes are to different attributes. The ImageQuest API does not provide any document locking mechanism -- it is up to the API consumers to ensure that data collisions do not occur.

Examples

The following example updates one of the index fields for an existing document and saves the changes to ImageQuest. Note that code checks to ensure that the attribute is in the Metadata array before attempting to update it. Attributes that have not yet been assigned a value will not be present in the array. (See IQDocument for more details.)

All example code is written in C#, using version 4 syntax and .NET 4.0.
using ( IIQAPI api = new ImageQuestService.IQAPIClient() )
{
   string token = api.SystemLogin("ImageQuest");

   // Retrieve an existing document by it's document ID.
   IQDocument document = api.GetDocument(token, documentId);
   List<IQAttribute> metadata = new List<IQAttribute>(document.Metadata);

   // Extract (or, if necessary, add) the "Name" attribute for the document.
   IQAttribute name = metadata.SingleOrDefault(x => x.Name == "Name");
   if ( name == null ) 
   {
       name = new IQAttribute { Name = "Name" };
       metadata.Add(name);
   }
   name.Value = "New Customer Name";

   // Store our changes back to the document and save.
   document.Metadata = metadata.ToArray();
   api.UpdateDocument(token, ref document);
}
See Also