How to view all invoice properties without opening Validation Station

I cannot find any examples of accessing the ExtractionResults object to get all invoice property values. How can I access the final invoice values after the Validation code?

According to the documentation it looks like there may be a few ways to get the invoice properties. I see that the ExtractionResult can be turned into a dataSet then multiple dataTables, but I can’t seem to get the syntax to work when trying to log values. I also tried to use GetTableFieldValue(“invoice-no”), but it seems to be empty. Is there some way to view the actual objects in variables while debugging, like hovering over variables in visual studio, or could someone show me an example of accessing the ExtractionResults invoice properties?

1 Like

EDIT: The following can also be used for ExtractionResults that you get from Extraction Scope, without validation.


If you serialize ValidatedExtractionResults (ValidatedExtractionResults.Serialize) - it will return a string of serialized JSON that you can Deserialize into JObject and then work with it as you would with any other JSON file.

This string is helpful to save to a file first, so you can see the structure of the data, so you can find your way to navigate through it.

To access the data within your script, you just need to drop Deserialize JSON activity after Validation Station activity and use the following arguments:

  • Input JsonString would be your serialized results - ValidatedExtractionResults.Serialize
  • Output JsonObject would be a new variable of type JObject say we call it json

And then you can access your data like this:

  • To get ID of the first field that you defined in Extractors:
    json.Item("ResultsDocument").Item("Fields").Item(0).Item("FieldId").ToString
  • To get the value of the same field:
    json.Item("ResultsDocument").Item("Fields").Item(0).Item("Values").Item(0).Item("Value").ToString
4 Likes

A small addition to this, I actually started to use JSONPath to navigate through JObject, it’s much easier and much more flexible than using the full “path” that I mentioned above.

Useful links:
The documentation - https://goessner.net/articles/JsonPath/
An interactive online evaluator that I use - https://jsonpath.com/

To use that in UiPath, you need to use JObject.SelectToken method, for example:

json.SelectToken("$..emailAddr").Value(Of String)

This would allow you to find and get a value of emailAddr in a JObject no matter where or how deep it is located. This is a bit vague, but I hope you get the point.

Just read the documentation and go play around with the online evaluator and see for yourself.

1 Like

Hi @cubx
Can you please post the sample xaml of extraction data from JSON using JSONPATH.

Thanks

Hello @Vinod_Swain,

Here you go.
JsonPath_demo.zip (5.9 KB)

Put your API key and amend the filename (the first 2 Assign activities) if you want to see it in action.

1 Like

Thanks

Hi, Cubx, great advice, thank you!

I’m wondering if you could help me further:
I read “vendor-address” with ML extractor into a field “vendor-address”.
After deserialize extractionResults into JSON I extract street value from vendor-address and
want to write it back to field “street” in JSON to prepare it for human validation.

Now, my question is, how to write the extracted street value into the field “street” in JSON
(extractionResult variable):
“FieldId”: “Group1.Invoice.Street”,
“FieldName”: “Street”,
“FieldType”: “Text”,
“IsMissing”: true,
“DataSource”: “Automatic”,
“Values”: ,
“DataVersion”: 0,
“OperatorConfirmed”: false

I hope I was clear enough.

Thank you very much in advance.
Regards, Vanja

1 Like

Hello all,

Recommended way of dealing with this is through the “Export Extraction Results” activity, with or without the checked “Include Confidnce” flags. Please give it a try and see if it helps you.

You can check out how it is used in here: How to use the IntelligentOCR Package .

Ioana

Hi, I got the solution from other source.
I do not write the value(s) to JSON file, but instead to extractionResult variable directly:

extractionResults.ResultsDocument.Fields.First(Function(i As ResultsDataPoint) i.FieldName = “Street”).Values(0).Value = vcStreet

Regards,
Vanja

2 Likes