Set field properties in multiple documents

You can set document properties in multiple documents using the CreateDocuments2 API method.

The CreateDocuments API method supports the creation of multiple documents. The following changes will allow for the initialization of each new document’s field properties.

[SecuritySafeCritical]
public DocumentIdentityCollection CreateDocuments2(
string sessionId,
ReportingData reportingData,
string parentId,
RuntimeFieldCollection runtimeFolderFields,
string folderTypeId,
DocumentDataInput2Collection documentData)

See the following table for description of classes and properties.

DocumentDataInput2Collection

This class is a collection of DocumentDataInput2.

DocumentDataInput2

This input is defined as:

public class DocumentDataInput2 : DocumentDataInput
{
public FieldPropertiesCollection FieldProperties { get; set; }
}

Sample Code for creating multiple documents

The following code sample demonstrates the creation of two documents using CreateDocuments2. During the creation of the documents, the Valid, Confidence, and Value properties of two fields of each document are set to new values.

const string ValidPropertyId = "5B83535412F142669762C8C08CFE690F";
const string ConfidencePropertyId = "079B5DD225E94E1FA058999481DE8023";
const string ValuePropertyId = "0B8889DC16EA4F32AFFED1A48E49A720";
var reportingData = new ReportingData();
var cds = new CaptureDocumentService();
var properties = new FieldSystemPropertyCollection
{
new FieldSystemProperty { SystemFieldIdentity = new FieldSystemPropertyIdentity() { Name = “Top” }, Value = 350 },
new FieldSystemProperty { SystemFieldIdentity = new FieldSystemPropertyIdentity() { Name = “Left” }, Value = 95 }
};
var properties2 = new FieldSystemPropertyCollection
{
new FieldSystemProperty { SystemFieldIdentity = new FieldSystemPropertyIdentity() { Id = ValidPropertyId }, Value = true },
new FieldSystemProperty { SystemFieldIdentity = new FieldSystemPropertyIdentity() { Id = ConfidencePropertyId }, Value = 0.91 },
new FieldSystemProperty { SystemFieldIdentity = new FieldSystemPropertyIdentity() { Id = ValuePropertyId }, Value = "Test" }
};
var fieldProperties = new FieldPropertiesCollection
{
new FieldProperties(new RuntimeFieldIdentity("FirstName"), properties),
new FieldProperties(new RuntimeFieldIdentity("Address"), properties2)
};
var fieldProperties2 = new FieldPropertiesCollection
{
new FieldProperties(new RuntimeFieldIdentity("City"), properties),
new FieldProperties(new RuntimeFieldIdentity("Phone"), properties2)
};

DocumentDataInput2Collection docData = new DocumentDataInput2Collection {
new DocumentDataInput2() {
FieldProperties = fieldProperties
},
new DocumentDataInput2() {
FieldProperties = fieldProperties2
}
};
cds.CreateDocuments2("", reportingData, "", null, null, docData);