activities
latest
false
Document Understanding Activities
Last updated Oct 4, 2024

PREVIEW
Methods

The Generate Data Type setting in the Extract Document Data activity determines the Document Data output types:

  1. When Generate Data is True, Document Data outputs as IDocumentData<ExtractorType>.
  2. When Generate Data is False, Document Data outputs as IDocumentData<DictionaryData>.
The IDocumentData<DictionaryData> type allows you to retrieve and modify field values using certain methods. You can also change the document type in the Validation Station.
The following sections show the available methods for DocumentData.Data.
Note: The fieldIdOrName parameter is treated both as the identifier and name of the field.

GetFields()

Returns all the information from fields within a document type, except table fields.

Syntax

GetFields()GetFields()

Return value

An array of all the fields and their associated extracted values.

Example

Check the following example for using the method:

ResultsDataPoint[] allFields = DocumentData.Data.GetFields()ResultsDataPoint[] allFields = DocumentData.Data.GetFields()

GetField(string)

Returns all field information, based on a given field ID or name.

Syntax

GetField(string fieldIdOrName)GetField(string fieldIdOrName)

Parameters

fieldIdOrName String
The ID or name of the field you want to retrieve or set. The method first searches for a match using the ID. If not match is found, it then searches using the same value as the name of the field.
You can discover the field ID and name in the following ways:
  • Navigate to the Build section of your project. Select Document type manager for a sample document. Proceed to Fields, then select Advanced Settings for the relevant field.


  • Open the Validation Station, and under Document Type, search for existent field names.
  • If you are using Document Understanding APIs, you can use the APIs within the Discovery service to retrieve the field names and IDs. Visit Use the Discovery APIs for checking the available API calls.

Return value

The field and its associated extracted values.

Example

Check the following example for using the method, when the desired field ID or name is vendor:
ResultsDataPoint vendorData = DocumentData.Data.GetField("vendor");ResultsDataPoint vendorData = DocumentData.Data.GetField("vendor");

GetFieldValue(string)

Returns the first field value, based on a given field ID or name.

Syntax

GetFieldValue(string fieldIdOrName)GetFieldValue(string fieldIdOrName)

Parameters

fieldIdOrName String
The ID or name of the field you want to retrieve or set. The method first searches for a match using the ID. If not match is found, it then searches using the same value as the name of the field.
You can discover the field ID and name in the following ways:
  • Navigate to the Build section of your project. Select Document type manager for a sample document. Proceed to Fields, then select Advanced Settings for the relevant field.


  • Open the Validation Station, and under Document Type, search for existent field names.
  • If you are using Document Understanding APIs, you can use the APIs within the Discovery service to retrieve the field names and IDs. Visit Use the Discovery APIs for checking the available API calls.

Return value

The value reported for a field in an extraction result.

Exceptions

If the fieldIdOrName is not found, then the following exception is thrown: Field {FieldIDOrName} not found.

Example

Check the following example for using the method, when the field ID or name is vendor:
ResultsValue fieldValue = DocumentData.Data.GetFieldValue("vendor");
    // stores the value of the fieldValue object in a string variable   
    string value = fieldValue.Value;
    // stores the confidence of the fieldValue object in a float variable
    float confidence = fieldValue.Confidence;ResultsValue fieldValue = DocumentData.Data.GetFieldValue("vendor");
    // stores the value of the fieldValue object in a string variable   
    string value = fieldValue.Value;
    // stores the confidence of the fieldValue object in a float variable
    float confidence = fieldValue.Confidence;

GetFieldValue(string, int)

Returns a field value, based on a given field ID or name, as well as the field index, to return a specific value from the values array.

This method applies to simple fields.

Syntax

GetFieldValue(string fieldIdOrName, int index)GetFieldValue(string fieldIdOrName, int index)

Parameters

fieldIdOrName String
The ID or name of the field you want to retrieve or set. The method first searches for a match using the ID. If not match is found, it then searches using the same value as the name of the field.
You can discover the field ID and name in the following ways:
  • Navigate to the Build section of your project. Select Document type manager for a sample document. Proceed to Fields, then select Advanced Settings for the relevant field.


  • Open the Validation Station, and under Document Type, search for existent field names.
  • If you are using Document Understanding APIs, you can use the APIs within the Discovery service to retrieve the field names and IDs. Visit Use the Discovery APIs for checking the available API calls.
index Int
The index of a specific value.

Return value

The value reported for a field in an extraction result.

Exceptions

  • If the fieldIdOrName is not found, then the following exception is thrown: Field {fieldIdOrName} not found.
  • If the index is not found, then the following exception is thrown: Index is out of range.

Example

Check the following example for using the method, where field ID is vendor, and the index for the desired value is 2:
ResultsValue fieldValue = DocumentData.Data.GetFieldValue("vendor", 2);
    // store the retrieved value in a string variable
    string value = fieldValue.Value;
    // retrieve and store the confidence level of the field value
    float confidence = fieldValue.ConfidenceResultsValue fieldValue = DocumentData.Data.GetFieldValue("vendor", 2);
    // store the retrieved value in a string variable
    string value = fieldValue.Value;
    // retrieve and store the confidence level of the field value
    float confidence = fieldValue.Confidence

GetFieldValues(string)

Returns all values of a field from a document type, based on a given field ID or name.

This method applies not only to multi-value fields but also to fields for which the extraction model provides alternative values. This means a field can have more than one value for alternatives, even if it is not inherently a multi-value field.

Syntax

GetFieldValues(string fieldIdOrName)GetFieldValues(string fieldIdOrName)

Parameters

fieldIdOrName String
The ID or name of the field you want to retrieve or set. The method first searches for a match using the ID. If not match is found, it then searches using the same value as the name of the field.
You can discover the field ID and name in the following ways:
  • Navigate to the Build section of your project. Select Document type manager for a sample document. Proceed to Fields, then select Advanced Settings for the relevant field.


  • Open the Validation Station, and under Document Type, search for existent field names.
  • If you are using Document Understanding APIs, you can use the APIs within the Discovery service to retrieve the field names and IDs. Visit Use the Discovery APIs for checking the available API calls.

Return value

An array of values reported for a field in an extraction result.

Exceptions

If the fieldIdOrName is not found, then the following exception is thrown: Field {fieldIdOrName} not found.

Example

Check the following example for using the method, where field ID is vendor:
ResultsValue[] fieldValues = DocumentData.Data.GetFieldValues("vendor");ResultsValue[] fieldValues = DocumentData.Data.GetFieldValues("vendor");

GetTables()

Returns all field information from all tables within a document type.

Syntax

GetTables()GetTables()

Return value

The extracted table field as an array, containing one or multiple ResultsTableValues (to support single and multi-value tables, respectively). Each value has an array of ResultsTableCells. Each cell has an array of ResultsValue which is the standard value object used for simple fields.

Example

Check the following example for using the method:

ResultsTable[] tableValues = DocumentData.Data.GetTables();ResultsTable[] tableValues = DocumentData.Data.GetTables();

GetTable(string)

Returns all field information from a table within a document type, based on a given ID.

Syntax

GetTable(string tableID)GetTable(string tableID)

Parameters

tableID String
The ID of the table you want to retrieve. You can find the table ID by navigating to the Build section of your project. Select Document type manager for sample document. Proceed to Fields, then select Advanced Settings for the relevant table field.


Return value

The extracted table field, containing one or multiple ResultsTableValues (to support single and multi-value tables, respectively). Each value has an array of ResultsTableCells. Each cell has an array of ResultsValue which is the standard value object used for simple fields.

Example

Check the following example for using the method, where table ID is prices:
var tableValues = DocumentData.Data.GetTable("prices");var tableValues = DocumentData.Data.GetTable("prices");

SetFieldValue(string, ResultsValue)

Overwrites an entire array of values identified by field ID, with the specified value.

Syntax

SetFieldValue(string fieldID, ResultsValue value)SetFieldValue(string fieldID, ResultsValue value)

Parameters

fieldIdOrName String
The ID or name of the field you want to retrieve or set. The method first searches for a match using the ID. If not match is found, it then searches using the same value as the name of the field.
You can discover the field ID and name in the following ways:
  • Navigate to the Build section of your project. Select Document type manager for a sample document. Proceed to Fields, then select Advanced Settings for the relevant field.


  • Open the Validation Station, and under Document Type, search for existent field names.
  • If you are using Document Understanding APIs, you can use the APIs within the Discovery service to retrieve the field names and IDs. Visit Use the Discovery APIs for checking the available API calls.
value ResultsValue
The value that you want to set for a field.

Exceptions

If the fieldID is not found, then the following exception is thrown: Field {FieldIDOrName} not found.

Example

Check the following example for using the method, where we first create the field value using the ResultsValue.CreateWithNoReference helper method. The helper method takes the following parameters:
  • First parameter represents the value.
  • Second parameter represents the confidence.
  • Third parameter represents the OCR confidence.
After creating the taxValue field value object, we replace the potential pre-existing values of the tax field (if any exist) with a new array containing only the taxValue object. In this instance, the field tax will assume the new value 10 as we use SetFieldValue.
var taxValue = ResultsValue.CreateWithNoReference("10", 1, 1);
documentData.Data.SetFieldValue("tax", taxValue);var taxValue = ResultsValue.CreateWithNoReference("10", 1, 1);
documentData.Data.SetFieldValue("tax", taxValue);

SetFieldValue(string, ResultsValue, int)

Sets a field value, based on a given field ID or name, and based on a field index.

This method applies to simple fields.

Syntax

SetFieldValue(string fieldID, ResultsValue value, int index)SetFieldValue(string fieldID, ResultsValue value, int index)

Parameters

fieldIdOrName String
The ID or name of the field you want to retrieve or set. The method first searches for a match using the ID. If not match is found, it then searches using the same value as the name of the field.
You can discover the field ID and name in the following ways:
  • Navigate to the Build section of your project. Select Document type manager for a sample document. Proceed to Fields, then select Advanced Settings for the relevant field.


  • Open the Validation Station, and under Document Type, search for existent field names.
  • If you are using Document Understanding APIs, you can use the APIs within the Discovery service to retrieve the field names and IDs. Visit Use the Discovery APIs for checking the available API calls.
value ResultsValue
The value that you want to set for a field.
index Int
The index of a specific value.

Exceptions

  • If the fieldID is not found, then the following exception is thrown: Field {FieldIDOrName} not found.
  • If the index is not found, then the following exception is thrown: Index is out of range.

Example

Check the following example for using the method, where we first create the field value using the ResultsValue.CreateWithNoReference helper method. The helper method takes the following parameters:
  • First parameter represents the values array.
  • Second parameter represents the confidence.
  • Third parameter represents the OCR confidence.
After creating the taxValue field value object, we proceed to replace the value at index 1 of the tax field array with this new taxValue object. Here, the SetFieldValue method is used to replace the value at index 1.
var taxValue = ResultsValue.CreateWithNoReference("10", 1, 1);
documentData.Data.SetFieldValue("tax", new [] {taxValue}, 1);var taxValue = ResultsValue.CreateWithNoReference("10", 1, 1);
documentData.Data.SetFieldValue("tax", new [] {taxValue}, 1);

SetFieldValues(string, ResultsValue[])

Replaces the entire array of values with another specified value array, for a given field ID or name.

Syntax

SetFieldValues(string fieldID, ResultsValue[] values)SetFieldValues(string fieldID, ResultsValue[] values)

Parameters

fieldIdOrName String
The ID or name of the field you want to retrieve or set. The method first searches for a match using the ID. If not match is found, it then searches using the same value as the name of the field.
You can discover the field ID and name in the following ways:
  • Navigate to the Build section of your project. Select Document type manager for a sample document. Proceed to Fields, then select Advanced Settings for the relevant field.


  • Open the Validation Station, and under Document Type, search for existent field names.
  • If you are using Document Understanding APIs, you can use the APIs within the Discovery service to retrieve the field names and IDs. Visit Use the Discovery APIs for checking the available API calls.
values ResultsValue[]
The array of values that you want to set for a field.

Exceptions

If the fieldID is not found, then the following exception is thrown: Field {FieldIDOrName} not found.

Example

Check the following example for using this method, where we first create two field value objects using the ResultsValue.CreateWithNoReference helper method : total1 and total2. The helper method accepts three parameters:
  1. First parameter represents the actual value.
  2. Second parameter represents he confidence value.
  3. Third parameter represents the OCR confidence value.
After creating these field values, we replace the values of a field named Total Amount with an array that includes total1 and total2.
var total1 = ResultsValue.CreateWithNoReference("100", 1, 1);
    var total2 = ResultsValue.CreateWithNoReference("200", 1, 1);
    documentData.Data.SetFieldValues("Total Amount", new []{total1, total2});var total1 = ResultsValue.CreateWithNoReference("100", 1, 1);
    var total2 = ResultsValue.CreateWithNoReference("200", 1, 1);
    documentData.Data.SetFieldValues("Total Amount", new []{total1, total2});

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.