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

Computervision text not working in IF

I created a small app, which basicly takes picture, send it to Computervision via flow and gets recognized text.

When I display returned text (variable Container) in label, everything is correct.

But...

When I use the same text variable in following IF:

If(StartsWith(Container,"AKH 40"),"H1-V-112N1AY",
StartsWith(Container,"AKE 434"),"17000-1(AY)",
StartsWith(Container, "ALF 552"),"118990",
StartsWith(Container, "ALF 553"),"12160-1(AY) ",
"NOT FOUND") it does seems to work randomly.

When text starts with ALF 553, it works, but with AKH or AKE it does not work...

 

Realy buzzled, what is the issue here...

6 REPLIES 6
Highlighted
Resolver II
Resolver II

Re: Computervision text not working in IF

Perhaps your returned data has some leading/trailing spaces that aren't readily visible but causing an issue?

Whatever you get returned back, I would select it and copy/paste into notepad to see if there are any leading/trailing/repeat spaces

Leading/trailing spaces can be handled using Trim(Container) rather than just Container

Highlighted
Dual Super User III
Dual Super User III

Re: Computervision text not working in IF

Hi @Tonisv73 

 

The formula seems to be correct, I carried out a test on my side and this was working for AKH and AKE values as well. I am guessing the incorrect error might result because of the returned result from the Flow. Can you try out below expression:
 
If(StartsWith(Trim(Container),"AKH 40"),"H1-V-112N1AY",
StartsWith(Trim(Container),"AKE 434"),"17000-1(AY)",
StartsWith(Trim(Container), "ALF 552"),"118990",
StartsWith(Trim(Container), "ALF 553"),"12160-1(AY) ",
"NOT FOUND")
 
This will remove any extra spaces if any.
 
Hope this Helps!

If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!
Highlighted
Frequent Visitor

Re: Computervision text not working in IF

Nop.. Did not worked

The flow sends back correct text:

2019-08-23 18_37_59-Run History _ Microsoft Flow.png

 

Highlighted
Dual Super User III
Dual Super User III

Re: Computervision text not working in IF

Hi @Tonisv73 

 

Can you please share the expression that you are using to set this variable?
Highlighted
Frequent Visitor

Re: Computervision text not working in IF

Sorry for late reply, but the build goes as this:

First this is created:

ClearCollect(PartNumbers,
Table(
{Serialnr:"AKH 40", Partnr:"H1-V-112N1"},
{Serialnr:"AKH 508", Partnr:"H1-V-112N2"},
{Serialnr:"ICH 5", Partnr:"H1S-V-A12N1"},
{Serialnr:"AKE 43", Partnr:"17000-1"},
{Serialnr:"ALF 552", Partnr:"118990"},
{Serialnr:"ALF 553", Partnr:"12160-1"},
{Serialnr:"ALF 554", Partnr:"12160-1"},
{Serialnr:"AAP 9", Partnr:"UA-115633-1"},
{Serialnr:"ALP 6", Partnr:"UA-115607-1"}))

 

Then in Powerapps Camera controll on select:

Set(Container, "xxx 1234567");
ClearCollect(ColPhoto,Camera1.Photo);
Set (varOCR,PowerAppsOCR.Run(First(ColPhoto).Url).ocrtext);
Set(varOCRlenght, Len(varOCR));
If(Mid(varOCR,4,1)<> " ",Set(varOCR, Left(varOCR,3)&" "&Right(varOCR,varOCRlenght-3)));
If(varOCRlenght < 10, Set (varOCR, varOCR & " XX"));
Set(Container,Trim(PlainText(varOCR)))

 

Container is set as default to TextInput1, so in case OCR was not correct, it can be edited there.

 

Then there was originaly this if, but now I replaced it with gallery and it should pick correct as default via Gallery default:

First(Filter(PartNumbers,StartsWith(TextInput1.Text,Serialnr)))

 

Still with some it pick's correct, mostly not and if I manualy overwrite the text in TextInput1 with excatly the same text, then it works...

Highlighted
Dual Super User III
Dual Super User III

Re: Computervision text not working in IF

Hi @Tonisv73 

 

Can you confirm that the response returned from flow is in the form of JSON and varOCR has the value that you are expecting? Also, why do you want to apply the manipulations on the returned response, is this a requirement?
 
To pick the value from the collection, update your expression as:
LookUp(PartNumbers,StartsWith(TextInput1.Text,Serialnr))
 
I think the issue here is with the way the textbox is getting populated, based on the expression shared by you, if returned response is "AKH 50864", then the value of container is "AKH 508 XX", this will not satisfy the condition based on the collection values.
 
Hope this Helps!
 
If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

secondImage

Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

secondImage

Super Users Coming in August

We are excited for the next Super User season.

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,193)