How do I change values of a table in extraction results?

Hi All,

I Have a data table defined in taxonomy. I need to make a look up and add values to the table. However I can’t do it in a data table variable as I need to pass this change into an extractionresult to send to action center.

Hence I’m trying to manipulate the extractionresults.results document variable and change the fields and values of it.

  1. How do I find which index my table is in and how do I find the index of columns?

Thank you!

Hi @sharon.palawandram ,

I was able to check on the modification to be done by using Json Serialize and Deserialize Methods.

Inspecting the Extraction Results Json :

  • First off, our taxonomy would always be fixed, this would also mean that the Table columns defined would also be fixed. Keeping that in mind, we can at the beginning check the extractionResults value by Serializing it to a String, so right after the Data Extraction Scope (I performed it in Extraction Rules Check workflow of DU Framework), we get the extraction results and we serialize it using the below Expression :
Newtonsoft.Json.JsonConvert.SerializeObject(io_ExtractionResults.ResultsDocument.Tables)

Visual :

You can write the serialized data to a text file or a Json file.

  • Next, Observe the Data in the text/Json file.
  • We can observe that the row data that is presented is available in the Cells Json array.

    File attached for reference :
    DS-00223908.txt (9.9 KB)
  • In the Cells array, each Object in the array each of the cell in the table, and using the rowIndex and columnIndex we are able to create/position the values in the table.
  • The rowIndex being 0, with IsHeader property being true, would marked the headers/column names of the Table.
  • Now that we understand this structure, we should be able to create a Template out of it, by just keeping the Headers and removing the other row/cell object data. So the modified template would be like below :
    Invoice_Table_ExtractionResult.txt (5.4 KB)

Below, we see the modified part :

  • Removed the cell Objects having rowIndex greater than 0 as it was the data values.

  • We have added a Placeholder -Cells- in place of it, so that we could populate our data in the required format.

  • Next, we have to also keep the template of the cell object ready. Observe the template and the placeholders in it - -RowIndex-,-ColumnIndex-,-CellValue-
    image
    File :
    ExtractionResult_TableCell.json (417 Bytes)

  • Above Steps are a One Time operation, to keep the templates ready.

Creating the Results Table Json Data by populating external table data:

  • Now, using the two templates we should be able to build up the Extraction Results Json data and then Deserialize it back to the ResultsTable() type.

  • Read the two templates, store the result into String variables.

  • Create a variable to store the all cells data from the datatable.

  • We can then loop over the rows and the column values of the datatable to populate the Json data.

  • Next, we check if there was any data to populate, if so, then add the generated cells data to the Extraction Results Json Data by replacing -Cells- placeholder with the generated data.
    image

  • In the else part of if, we are just replacing ,-Cells- placeholder with an Empty value, marking that there are no rows in the datatable.
    image

  • Last, we convert the generated Extraction Results Table Json Data to ResultsTable() type using the below Expression :

io_ExtractionResults.ResultsDocument.Tables = Newtonsoft.Json.JsonConvert.DeserializeObject(Of ResultsTable())(extractionResultTable_Format)

image

Attaching the workflow below which consists of the modification Steps mentioned above, however it was part of a VB, Windows - Document Understanding Template Process, it should be able to open in the same type of workflow without any errors.
InvoicePostProcessing.xaml (73.1 KB)

This is an unconventional method, However I did test it out, and it did work as I was able to get the changed values in the Action Center Validation Station.

2 Likes

Hi Arpan,

Works like magic, thank you for giving one of the best illustrated explanations I’ve seen.

Thank you!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.