cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ford_wilkinson
Frequent Visitor

Trying to use Form processing in a flow and getting "ExpressionEvaluationFailed. The execution of template action 'Line_Items' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['predictionOutput']?['tables']?['table_0']?['entries']' is of type 'Null'. The result must

I am trying to use the Form Processor to automate vendor invoice processing.  When it tries to process an invoice, I have a table that has been trained to pick up the line items for the invoice.  My flow is creating the JSON from the Predict step and is parsing it.  While it is SKIPPING some lines (it only processed the last 2 of 3 lines) it IS processing and picking up all the fields for those 2 lines.  When it gets to the step where I am using those line values, I am getting the error:  "ExpressionEvaluationFailed. The execution of template action 'Line_Items' failed: the result of the evaluation of 'foreach' expression '@body('Parse_JSON')?['predictionOutput']?['tables']?['table_0']?['entries']' is of type 'Null'. The result must be a valid array.""

 

I tried to attach the invoice but apparently I don't have permissions.

 

I can't get past it.  Any help on this "type 'Null' issue?  I still can't figure out the missing line issue.

 

Here is the Parsed JSON.  You can see it picked up on the lines with CODE C0004 and S0001 (not C0001) and it looks like all field values are listed for those 2 lines.

{
"predictionOutput": {
"labels": {
"Date": {
"displayName": "Date",
"value": "30 Oct 2019",
"valueLocation": {
"pageNumber": 1,
"boundingBox": {
"left": 0.8311764705882353,
"top": 0.20272727272727273,
"width": 0.08352941176470596,
"height": 0.008636363636363664,
"polygon": {
"coordinates": [
{
"x": 0.8311764705882353,
"y": 0.20272727272727273
},
{
"x": 0.9147058823529413,
"y": 0.20272727272727273
},
{
"x": 0.9147058823529413,
"y": 0.2113636363636364
},
{
"x": 0.8311764705882353,
"y": 0.2113636363636364
}
]
}
}
},
"confidence": 0.99
},
"Total": {
"displayName": "Total",
"value": "5720",
"valueLocation": {
"pageNumber": 1,
"boundingBox": {
"left": 0.8623529411764705,
"top": 0.8113636363636364,
"width": 0.03176470588235292,
"height": 0.008636363636363553,
"polygon": {
"coordinates": [
{
"x": 0.8623529411764705,
"y": 0.8113636363636364
},
{
"x": 0.8941176470588235,
"y": 0.8113636363636364
},
{
"x": 0.8941176470588235,
"y": 0.82
},
{
"x": 0.8623529411764705,
"y": 0.82
}
]
}
}
},
"confidence": 0.999
},
"INVOICE": {
"displayName": "INVOICE",
"value": "11205",
"valueLocation": {
"pageNumber": 1,
"boundingBox": {
"left": 0.871764705882353,
"top": 0.21818181818181817,
"width": 0.038235294117647034,
"height": 0.008636363636363664,
"polygon": {
"coordinates": [
{
"x": 0.871764705882353,
"y": 0.21818181818181817
},
{
"x": 0.91,
"y": 0.21818181818181817
},
{
"x": 0.91,
"y": 0.22681818181818184
},
{
"x": 0.871764705882353,
"y": 0.22681818181818184
}
]
}
}
},
"confidence": 0.989
},
"Due on receipt": {
"displayName": "Due on receipt",
"value": "Due on receipt",
"valueLocation": {
"pageNumber": 1,
"boundingBox": {
"left": 0.5111764705882352,
"top": 0.4586363636363636,
"width": 0.11705882352941177,
"height": 0.011818181818181839,
"polygon": {
"coordinates": [
{
"x": 0.5111764705882352,
"y": 0.4586363636363636
},
{
"x": 0.628235294117647,
"y": 0.4586363636363636
},
{
"x": 0.628235294117647,
"y": 0.47045454545454546
},
{
"x": 0.5111764705882352,
"y": 0.47045454545454546
}
]
}
}
},
"confidence": 0.956
}
},
"tables": {
"Line items": {
"displayName": "Line items",
"columns": [
{
"name": "Code",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.09771764705882353,
"top": 0.5208363636363637,
"width": 0.049341176470588236,
"height": 0.011990909090909163,
"polygon": {
"coordinates": [
{
"x": 0.09771764705882353,
"y": 0.5208363636363637
},
{
"x": 0.14705882352941177,
"y": 0.5208363636363637
},
{
"x": 0.14705882352941177,
"y": 0.5328272727272728
},
{
"x": 0.09771764705882353,
"y": 0.5328272727272728
}
]
}
}
}
},
{
"name": "Qty",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.18692941176470587,
"top": 0.5208363636363637,
"width": 0.017976470588235316,
"height": 0.011990909090909163,
"polygon": {
"coordinates": [
{
"x": 0.18692941176470587,
"y": 0.5208363636363637
},
{
"x": 0.2049058823529412,
"y": 0.5208363636363637
},
{
"x": 0.2049058823529412,
"y": 0.5328272727272728
},
{
"x": 0.18692941176470587,
"y": 0.5328272727272728
}
]
}
}
}
},
{
"name": "Description",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.28088235294117647,
"top": 0.5208363636363637,
"width": 0.25327058823529414,
"height": 0.011990909090909163,
"polygon": {
"coordinates": [
{
"x": 0.28088235294117647,
"y": 0.5208363636363637
},
{
"x": 0.5341529411764706,
"y": 0.5208363636363637
},
{
"x": 0.5341529411764706,
"y": 0.5328272727272728
},
{
"x": 0.28088235294117647,
"y": 0.5328272727272728
}
]
}
}
}
},
{
"name": "Unit Price",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.749835294117647,
"top": 0.5203272727272727,
"width": 0.024670588235294222,
"height": 0.010863636363636298,
"polygon": {
"coordinates": [
{
"x": 0.749835294117647,
"y": 0.5203272727272727
},
{
"x": 0.7745058823529413,
"y": 0.5203272727272727
},
{
"x": 0.7745058823529413,
"y": 0.531190909090909
},
{
"x": 0.749835294117647,
"y": 0.531190909090909
}
]
}
}
}
},
{
"name": "Line Total",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.861764705882353,
"top": 0.5203272727272727,
"width": 0.032682352941176496,
"height": 0.010863636363636298,
"polygon": {
"coordinates": [
{
"x": 0.861764705882353,
"y": 0.5203272727272727
},
{
"x": 0.8944470588235295,
"y": 0.5203272727272727
},
{
"x": 0.8944470588235295,
"y": 0.531190909090909
},
{
"x": 0.861764705882353,
"y": 0.531190909090909
}
]
}
}
}
}
],
"entries": [
{
"Code": {
"value": "C0004",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.09771764705882353,
"top": 0.5450727272727273,
"width": 0.049341176470588236,
"height": 0.01200000000000001,
"polygon": {
"coordinates": [
{
"x": 0.09771764705882353,
"y": 0.5450727272727273
},
{
"x": 0.14705882352941177,
"y": 0.5450727272727273
},
{
"x": 0.14705882352941177,
"y": 0.5570727272727273
},
{
"x": 0.09771764705882353,
"y": 0.5570727272727273
}
]
}
}
},
"confidence": 1
},
"Qty": {
"value": "20",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.18692941176470587,
"top": 0.5450727272727273,
"width": 0.017976470588235316,
"height": 0.01200000000000001,
"polygon": {
"coordinates": [
{
"x": 0.18692941176470587,
"y": 0.5450727272727273
},
{
"x": 0.2049058823529412,
"y": 0.5450727272727273
},
{
"x": 0.2049058823529412,
"y": 0.5570727272727273
},
{
"x": 0.18692941176470587,
"y": 0.5570727272727273
}
]
}
}
},
"confidence": 1
},
"Description": {
"value": "Lifecam HD 5000",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.28088235294117647,
"top": 0.5450727272727273,
"width": 0.1318588235294118,
"height": 0.01200000000000001,
"polygon": {
"coordinates": [
{
"x": 0.28088235294117647,
"y": 0.5450727272727273
},
{
"x": 0.4127411764705883,
"y": 0.5450727272727273
},
{
"x": 0.4127411764705883,
"y": 0.5570727272727273
},
{
"x": 0.28088235294117647,
"y": 0.5570727272727273
}
]
}
}
},
"confidence": 1
},
"Unit Price": {
"value": "50",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.758164705882353,
"top": 0.5445727272727273,
"width": 0.016341176470588303,
"height": 0.01085454545454545,
"polygon": {
"coordinates": [
{
"x": 0.758164705882353,
"y": 0.5445727272727273
},
{
"x": 0.7745058823529413,
"y": 0.5445727272727273
},
{
"x": 0.7745058823529413,
"y": 0.5554272727272728
},
{
"x": 0.758164705882353,
"y": 0.5554272727272728
}
]
}
}
},
"confidence": 1
},
"Line Total": {
"value": "1000",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.861764705882353,
"top": 0.5445727272727273,
"width": 0.032682352941176496,
"height": 0.01085454545454545,
"polygon": {
"coordinates": [
{
"x": 0.861764705882353,
"y": 0.5445727272727273
},
{
"x": 0.8944470588235295,
"y": 0.5445727272727273
},
{
"x": 0.8944470588235295,
"y": 0.5554272727272728
},
{
"x": 0.861764705882353,
"y": 0.5554272727272728
}
]
}
}
},
"confidence": 1
}
},
{
"Code": {
"value": "S0001",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.09771764705882353,
"top": 0.5693181818181818,
"width": 0.044117647058823525,
"height": 0.011990909090909052,
"polygon": {
"coordinates": [
{
"x": 0.09771764705882353,
"y": 0.5693181818181818
},
{
"x": 0.14183529411764706,
"y": 0.5693181818181818
},
{
"x": 0.14183529411764706,
"y": 0.5813090909090909
},
{
"x": 0.09771764705882353,
"y": 0.5813090909090909
}
]
}
}
},
"confidence": 1
},
"Qty": {
"value": "1",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.18692941176470587,
"top": 0.5693181818181818,
"width": 0.008988235294117658,
"height": 0.011990909090909052,
"polygon": {
"coordinates": [
{
"x": 0.18692941176470587,
"y": 0.5693181818181818
},
{
"x": 0.19591764705882353,
"y": 0.5693181818181818
},
{
"x": 0.19591764705882353,
"y": 0.5813090909090909
},
{
"x": 0.18692941176470587,
"y": 0.5813090909090909
}
]
}
}
},
"confidence": 1
},
"Description": {
"value": "Installation Services",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.28088235294117647,
"top": 0.5693181818181818,
"width": 0.1516352941176471,
"height": 0.011990909090909052,
"polygon": {
"coordinates": [
{
"x": 0.28088235294117647,
"y": 0.5693181818181818
},
{
"x": 0.43251764705882356,
"y": 0.5693181818181818
},
{
"x": 0.43251764705882356,
"y": 0.5813090909090909
},
{
"x": 0.28088235294117647,
"y": 0.5813090909090909
}
]
}
}
},
"confidence": 1
},
"Unit Price": {
"value": "200",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.749835294117647,
"top": 0.5688090909090909,
"width": 0.024670588235294222,
"height": 0.010863636363636409,
"polygon": {
"coordinates": [
{
"x": 0.749835294117647,
"y": 0.5688090909090909
},
{
"x": 0.7745058823529413,
"y": 0.5688090909090909
},
{
"x": 0.7745058823529413,
"y": 0.5796727272727273
},
{
"x": 0.749835294117647,
"y": 0.5796727272727273
}
]
}
}
},
"confidence": 1
},
"Line Total": {
"value": "200",
"location": {
"pageNumber": 1,
"boundingBox": {
"left": 0.8697764705882353,
"top": 0.5688090909090909,
"width": 0.024670588235294222,
"height": 0.010863636363636409,
"polygon": {
"coordinates": [
{
"x": 0.8697764705882353,
"y": 0.5688090909090909
},
{
"x": 0.8944470588235295,
"y": 0.5688090909090909
},
{
"x": 0.8944470588235295,
"y": 0.5796727272727273
},
{
"x": 0.8697764705882353,
"y": 0.5796727272727273
}
]
}
}
},
"confidence": 1
}
}
]
}
},
"pageCount": 1,
"readResults": [],
"layoutName": "Contoso"
},
"operationStatus": "Success",
"error": null
}

1 ACCEPTED SOLUTION

Accepted Solutions

It was a "canned" solution I found here:  murrayfife/APInvoiceAutomation.  I'll try using your solution above and respond if I have any questions.  Thank you for the help.

View solution in original post

2 REPLIES 2
JoeF-MSFT
Power Apps
Power Apps

Hi @ford_wilkinson,

 

Thanks for posting this question.

 

Instead of using the Predict action and parsing the JSON, I recommend that you use the Process and save information from forms action you can find under the AI Builder connector. It's much simpler to use and doesn't require parsing JSON.

 

For tables returned by an AI model in a flow, you can retreive the value of its columns by selecting the output: {table name} {column name} value. For example, in my case I have a table named Items and two columns, Line total and Description. So to get the value for each row I select the outputs Items Line total value and Items Description value. 

 

2020-12-01_9-23-55.png

 

Once you select a column, Power Automate will automatically put the action where you are putting the value in an 'Apply to each' loop like this:

2020-12-01_9-24-28.png

 

Hope this helps! Out of curiosity, where did you learn about using the Predict action and parse JSON? We'd love to update that to use the simpler way that we have today. 🙂

It was a "canned" solution I found here:  murrayfife/APInvoiceAutomation.  I'll try using your solution above and respond if I have any questions.  Thank you for the help.

View solution in original post

Helpful resources

Announcements
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Kudoed Authors
Users online (2,247)