Set field properties in a single document

You can set document properties in a single document using the CreateDocument2 API method.

The CreateDocument API method supports the creation of a single document. The following changes will allow for the initialization of the new document’s field properties.

[SecuritySafeCritical]
public DocumentIdentity CreateDocument2(
string sessionId,
ReportingData reportingData,
string parentId,
RuntimeFieldCollection runtimeFields,
string filePath,
int insertIndex,
string documentTypeId,
string folderTypeId,
FieldPropertiesCollection fieldProperties)

See the following table for description of classes and properties.

FieldPropertiesCollection

This class is a collection of fieldProperties.

fieldProperties

This input allows you to specify field properties without having to specify their values as part of the runtimeFields input.

The fieldProperties is defined as:

public class FieldProperties
{
public RuntimFieldIdentity Identity { get; set; }
public FieldSystemPropertyCollection PropertyCollection { get; set; }
}

FieldSystemPropertyCollection

This class is a collection of FieldSystemProperty, which is defined as:

public class FieldSystemProperty
{
public FieldSystemPropertyIdentity SystemFieldIdentity { get; set; }
public object Value { get; set; }
}

Sample code for creating a document

The following code sample demonstrates the creation of a document using CreateDocument2. During the creation of the document, the Valid, Confidence, and Value properties of two fields of the 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)
};
cds.CreateDocument2("", reportingData, "", null, "", 0, "", null, fieldProperties);