cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
skelecopter
Helper II
Helper II

Incompatible type errors, despite all data being strings

I'm parsing a QR code with delimited information in it and setting each piece of information as a variable, as so:

 

SS1.PNG

These variables are also being collected and saved using SaveData then reloaded using LoadData. Here you can see that it is only giving an error for "HarvestID", but it varies what it will show this error on.

 

SS2.PNG

 

If the above error line is not present, the app works.

 

Each variable is defined and reloaded/used in the exact same way, but the problem in the screenshot is that for "HarvestID", the formula above returns type "Error", so Power Apps trying to set it again as type "Text". All my other global variables are shown correctly in the variable explorer. I have the variable in a label control, which shows this type error:

 

SS3.PNG

 

 

 

 

I can change the names of any of the variables that might show errors like this to get the studio to stop complaining (sometimes), but as soon as I reload the app, the same problems with the new variables.

 

Is there any clue what's going on here? I found an older post suggesting to clear my browser cache, which worked once running into this issue with another app but has never worked again.

1 ACCEPTED SOLUTION

Accepted Solutions
timl
Super User
Super User

@skelecopter 

Thanks for the clarification. It definitely sounds like a bug and I hope that Microsoft support come back with something useful.

In the interim, what if you were to coerce the "error" data type to a string? Does that remove the error and allow you to work more easily?

Set(HarvestID, IfError(First(colData).HarvestID, "");

 

View solution in original post

9 REPLIES 9

Does the QR Code always have "*" in it? If not, you need to handle the null case.

skelecopter
Helper II
Helper II

Yes, it is generated from another app, always in the same format. The first block of code and the rest of the app works if I remove the underlined Set formula in the second screenshot. I can cut the line out and copy it back and the errors go away, but reloading the app or trying to use it shows that it's still broken.

timl
Super User
Super User

Hi @skelecopter 

What I imagine is happening, is that if HarvestID is a numeric value, Power Apps has assigned a numeric data type to colData.HarvestID. If this is the case, you could try to resolve this error by explictly casting HarvestID to a string like so:

Set(HarvestID, Text(First(colData).HarvestID);

 

I had already attempted that, unfortunately. If I use Text(), I still have to cut and paste the code from screenshot #2 again to even keep working in the studio.

 

Even if I rename the variable, once I change it in all of my formulas, it breaks again. If I cut and paste the error line from that screenshot and move it to the bottom of the expression, it then threw errors on every variable other than HarvestID. Absolutely maddening.

 

I have submitted a support ticket because I've 99% sure this is a bug that I've found 5+ other posts about now over the past couple of years (e.g., https://powerusers.microsoft.com/t5/Building-Power-Apps/Global-variables-just-stopped-working/m-p/13...). Unfortunately, changing the version of the editor doesn't help either.

timl
Super User
Super User

@skelecopter 

Thanks for the clarification. It definitely sounds like a bug and I hope that Microsoft support come back with something useful.

In the interim, what if you were to coerce the "error" data type to a string? Does that remove the error and allow you to work more easily?

Set(HarvestID, IfError(First(colData).HarvestID, "");

 

skelecopter
Helper II
Helper II

Wow, yes, that actually works, though I have to wrap every variable in it to get it to keep working when I reload the app. Thank you! I will discuss this with Microsoft support when they call me and will add the results to my thread when I hear from them.

So for anyone reading in the future: Microsoft support told me to define my variables as "" in the OnStart. This worked, although I don't understand why it's necessary. 

 

timl's solution to use IfError also works. I am still convinced this is a bug.

timl
Super User
Super User

Thanks for the update @skelecopter - I think I agree with you. It shouldn't be necessary to initialise the variables to "" if you're only ever assigning text values to those variables. If anything, at least this provides another workaround.

Yes, the same thing happened just now when I went to replace some variable names. 🙄 So I guess I'll just leave it alone, lol.

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (4,962)