Skip to main content

Notifications

Community site session details

Community site session details

Session Id : QFwQkbrEIMlXzYMrOcLA91
Power Apps - Building Power Apps
Answered

Incompatible type errors, despite all data being strings

Like (0) ShareShare
ReportReport
Posted on 10 Dec 2021 19:14:55 by 113

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.

  • skelecopter Profile Picture
    113 on 17 Dec 2021 at 17:16:19
    Re: Incompatible type errors, despite all data being strings

    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.

  • timl Profile Picture
    35,018 Super User 2025 Season 1 on 16 Dec 2021 at 14:55:04
    Re: Incompatible type errors, despite all data being strings

    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.

  • skelecopter Profile Picture
    113 on 14 Dec 2021 at 16:37:54
    Re: Incompatible type errors, despite all data being strings

    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.

  • skelecopter Profile Picture
    113 on 13 Dec 2021 at 16:08:00
    Re: Incompatible type errors, despite all data being strings

    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.

  • Verified answer
    timl Profile Picture
    35,018 Super User 2025 Season 1 on 10 Dec 2021 at 23:10:45
    Re: Incompatible type errors, despite all data being strings

    @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 Profile Picture
    113 on 10 Dec 2021 at 21:38:57
    Re: Incompatible type errors, despite all data being strings

    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/1316203). Unfortunately, changing the version of the editor doesn't help either.

  • timl Profile Picture
    35,018 Super User 2025 Season 1 on 10 Dec 2021 at 21:30:14
    Re: Incompatible type errors, despite all data being strings

    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);

     

  • skelecopter Profile Picture
    113 on 10 Dec 2021 at 19:57:53
    Re: Incompatible type errors, despite all data being strings

    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.

  • AndreaMondello Profile Picture
    on 10 Dec 2021 at 19:38:40
    Re: Incompatible type errors, despite all data being strings

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

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 89 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 60

#3
stampcoin Profile Picture

stampcoin 48

Overall leaderboard