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?
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
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.
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.
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
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.
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.
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…
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
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 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.
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 ?
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