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
6 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 - JSONPath - XPath for JSON
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

3 Likes

Hello @VanjaV,

Adding our private conversation message in here for reference:

hello @VanjaV,

  1. if you need the Line Item Tax, you need to build your own custom model hosted in AIFabric and train it with this column included as well… the out of the box model does not contain this Line Item Tax column as you can see from the model schema.
  2. you can create a new ResultsValue and just add it to the Values array… you also do not need to serialize and deserialize this… you should instead just work with the ExtractionResult object - it is a plain old object you can manipulate however you want. Example: you can put an execute code (c# flavor is my favorite), and do something like
    ResultsDataPoint myField = extractionResults.ResultsDocument.Fields.Single(f => f.FieldName == “blabla”);
    field.Values = new ResultsValue { myNewResultsValue }; where the myNewResultsValue is a new ResultsValue(); and then the same field you set
    field.IsMissing = False; and you should be done.
    (probably syntax is not correct, but do explore something along these lines).
    It should be much better than parsing and editing a json…
2 Likes

Hello,
On my part I get that IsMissing is “read only”. So I can set that value only with the constructor. Would be nice to be able to change it directly (Example: if we have value coming from other source but still wish to present it in the action “validation”).
Do you see another work around to change the IsMissing attribute?
Best

1 Like

You are right @yrobert,

the IsMissing property cannot be set because it is automatically computed as a flag indicating whether Values (for a given ResultsDataPoint) is null or empty :slight_smile: I missed that, sorry about the confusion. So you don’t need to set it specifically, it will get reported (as a helper) to indicate the state of the Values collection within the specific field’s ResultsDataPoint.

Again, sorry for the confusion!

Ioana

@VanjaV
Hi VanjaV,

I tried the same but its returned boolean value.
I want to write the new value to a field Name ie overwrite the existing value.

Assign Activity :
ExtractionResults = ExtractionResults.ResultsDocument.Fields.First(Function(i As ResultsDataPoint) i.FieldName=“BillerCode”).Values(0).Value= “12345” → Value of type Boolean cannot be converted to ExtractionResult

How can I overwrite the value of a perticular filedname of ExtractionResults ?

Hi @Karuna ,

Example for string variable

Assign:

extractionResults.ResultsDocument.Fields.First(Function(i As ResultsDataPoint) i.FieldName = “FieldName”).Values =
New ResultsValue() { New ResultsValue(If(vFieldValue.Count>0, vFieldValue.Value.toString, “/”), New ResultsContentReference(), 1, 1) }

Sometimes I also change confidence value:

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

Example for button yes/no variable type:

VB.Net Code ():

Dim field As ResultsDataPoint
field = extractionResults.ResultsDocument.Fields.First(Function(i As ResultsDataPoint) i.FieldName = fieldName)

If (field.Values.Count() = 0) Then

field.Values = New ResultsValue() { New ResultsValue(value, New ResultsContentReference(), 1, 1) }

'field.IsMissing = False

Else

field.Values(0).Value = value

End If

image

Assign:
extractionResults.ResultsDocument.Fields.First(Function(i As ResultsDataPoint) i.FieldId = “JSON FieldName like Group1.xxxx.xxxx.Flagxxx”).Values(0).OperatorConfirmed =
True

I hope this helped somehow.

Kind Regards,
Vanja

3 Likes

@VanjaV
Thank you. Its helpful.

There is complete video out there expalining various details on extracting and working on various field results of data extraction scope: Any one following this thread may get help: Present Validation Station (Appear Based on Confidence Score - UiPath) - YouTube