# Methods

> The **Generate Data Type** setting in the [Extract Document Data](https://docs.uipath.com/activities/other/latest/document-understanding/extract-document-data#extract-document-data) activity determines the Document Data output types:

The **Generate Data Type** setting in the [Extract Document Data](https://docs.uipath.com/activities/other/latest/document-understanding/extract-document-data#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()
```

### Return value

[`ResultsDataPoint[]`](/activities/other/latest/document-understanding/results-data-point-class)

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()
```

## `GetField(string)`

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

### Syntax

```
GetField(string fieldIdOrName)
```

### Parameters

* **`fieldIdOrName`** [String](https://learn.microsoft.com/dotnet/api/system.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.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-448250-a8df986f-5d16f409.webp)

    * 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](https://docs.uipath.com/document-understanding/automation-cloud/latest/api-guide/use-the-discovery-service) for checking the available API calls.

### Return value

[`ResultsDataPoint`](https://docs.uipath.com/activities/other/latest/document-understanding/results-data-point-class)

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");
```

## `GetFieldValue(string)`

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

### Syntax

```
GetFieldValue(string fieldIdOrName)
```

### Parameters

* **`fieldIdOrName`** [String](https://learn.microsoft.com/dotnet/api/system.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.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-448250-a8df986f-5d16f409.webp)

    * 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](https://docs.uipath.com/document-understanding/automation-cloud/latest/api-guide/use-the-discovery-service) for checking the available API calls.

### Return value

[`ResultsValue`](https://docs.uipath.com/activities/other/latest/document-understanding/results-value-class)

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;
```

## `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)
```

### Parameters

* **`fieldIdOrName`** [String](https://learn.microsoft.com/dotnet/api/system.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.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-448250-a8df986f-5d16f409.webp)

    * 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](https://docs.uipath.com/document-understanding/automation-cloud/latest/api-guide/use-the-discovery-service) for checking the available API calls.

* **`index`** [Int](https://learn.microsoft.com/dotnet/api/system.int32) : The index of a specific value.

### Return value

[`ResultsValue`](https://docs.uipath.com/activities/other/latest/document-understanding/results-value-class)

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.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)
```

### Parameters

* **`fieldIdOrName`** [String](https://learn.microsoft.com/dotnet/api/system.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.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-448250-a8df986f-5d16f409.webp)
    * 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](https://docs.uipath.com/document-understanding/automation-cloud/latest/api-guide/use-the-discovery-service) for checking the available API calls.

### Return value

[`ResultsValue[]`](/activities/other/latest/document-understanding/results-value-class)

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");
```

## `GetTables()`

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

### Syntax

```
GetTables()
```

### Return value

[`ResultsTable[]`](/activities/other/latest/document-understanding/229-resultstable-class "The ResultsTable class represents the extracted table field.")

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();
```

## `GetTable(string)`

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

### Syntax

```
GetTable(string tableID)
```

### Parameters

* `tableID` [String](https://learn.microsoft.com/dotnet/api/system.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.

![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-448250-a8df986f-5d16f409.webp)

### Return value

[`ResultsTable`](https://docs.uipath.com/activities/other/latest/document-understanding/229-resultstable-class "The ResultsTable class represents the extracted table field.")

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");
```

## `SetFieldValue(string, ResultsValue)`

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

### Syntax

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

### Parameters

* **`fieldIdOrName`** [String](https://learn.microsoft.com/dotnet/api/system.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.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-448250-a8df986f-5d16f409.webp)
    * 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](https://docs.uipath.com/document-understanding/automation-cloud/latest/api-guide/use-the-discovery-service) for checking the available API calls.

* `value` [ResultsValue](https://docs.uipath.com/activities/other/latest/document-understanding/results-value-class) : 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);
```

## `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)
```

### Parameters

* **`fieldIdOrName`** [String](https://learn.microsoft.com/dotnet/api/system.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.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-448250-a8df986f-5d16f409.webp)
    * 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](https://docs.uipath.com/document-understanding/automation-cloud/latest/api-guide/use-the-discovery-service) for checking the available API calls.

* `value` [ResultsValue](https://docs.uipath.com/activities/other/latest/document-understanding/results-value-class) : The value that you want to set for a field.

* **`index`** [Int](https://learn.microsoft.com/dotnet/api/system.int32) : 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);
```

## `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)
```

### Parameters

* **`fieldIdOrName`** [String](https://learn.microsoft.com/dotnet/api/system.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.

    ![docs image](https://dev-assets.cms.uipath.com/assets/images/activities/document-understanding-docs-image-448250-a8df986f-5d16f409.webp)
    * 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](https://docs.uipath.com/document-understanding/automation-cloud/latest/api-guide/use-the-discovery-service) for checking the available API calls.

* **`values`** [ResultsValue](https://docs.uipath.com/activities/other/latest/document-understanding/results-value-class)[] : 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});
```
