cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
DaveTaylorNHS
Regular Visitor

Can Apps corrupt to cause Unrecoverable Incompatible Type errors

So I use context variables on screens that are loaded with data from a sharepoint list, normally when the screen is navigated to.

e.g.

Navigate(MyScreen, Fade, {varMode: "View", varRecord: LookUp(MyList, ID=ThisItem.ID)})

I then update the variable in the OnChange box of whatever control it is that I am using, making sure I use Text or Value to define the type as I have been bitten in the past by Incompatible Type.

e.g.

UpdateContext({varRecord: Patch(varRecord, {Title: Text(Self.Text)})})

I have done this many times and have many apps that use this method at there core.

 

What I have found, it that in some apps, when I get Incompatible Type Error, there is nothing that I can do to get rid of it. I know that all of the data types are matching and if I use the same code and data in another app it works as intended. However if I copy controls over, or save it at something else or create a new copy based on an export/import it seems to follow.

 

Can someone point me at what to read to get a better understanding of why this happens? Its just happened to me again as I am nearing the end of the App and now I have to redo whole chunks of it using code I have used hundreds of times before with no issues.

 

Frustrated from the NHS

4 REPLIES 4
BCBuizer
Super User
Super User

Hi @DaveTaylorNHS ,

 

Only thing that comes to mind is perhaps you are using the same variable with a different data schedule within the same context.

Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
DaveTaylorNHS
Regular Visitor

@BCBuizer 

Thank you for replying, I am not sure what you mean by data schedule, perhaps you could elaborate. The only definition happening to the variable are all based on an update to an individual item in the record or its initial definition based on a looked up record.

DaveTaylorNHS_0-1652512084573.png

 

 

BCBuizer
Super User
Super User

Hi @DaveTaylorNHS,

 

I meant data scheme: how your data is structured, column names, data types, etc. Looking from you screenshot I don't see anything obviously out of the ordinary, but I don't know the details of your data source.

 

When trying to replicate the issue, I didn't run into any issues, so can you please share the exact error message you are getting?

Did you like my post? Please give it a thumbs up! Did I resolve your issue? Please click Accept as Solution to close the topic and so other members of the community can find solutions more easily.
DaveTaylorNHS
Regular Visitor

So the Exact Error Message is the normal Incompatible type, which then causes errors in anything referencing or related to the variable in question.

 

I have now resolved my issue by going line by line and rebuilding from nothing, putting each call in one at a time until I got an error. As the error only appears on a program load, this was a lot of saving and opening over the course of the weekend. 

 

I did find a control that was being referenced without the 'required' TEXT function around it and that I thought that was it.

 

However, my app makes a lot of related calls e.g. you have Incidents and they may have actions against them, but you could also have an action related to something else. To manage the UI, I store what calls the screen so that I can navigate back. This means more than one call defining the same context variable based on the same data source and as soon as I started putting them back in, I started getting the error again.

 

I recall seeing another article saying you should define the variable in OnStart, so I converted all my variable calls to Global Variables, rather than context, and defined them in OnStart with a Blank(). This also worked for a bit until I started re-introducing the code that was in my OnVisible, which basically put an update on on a new record that you did not worry about in the UI, e.g. ID of the routine creating the action.

 

Changing my OnStart Definitions to base it on the record I wanted e.g. Lookup(datasource, ID=-1) fixed this, though I only need to do that one the variables that did things OnVisible.

 

It was a total chore working through all the iterations and extremely frustrating, but I stuck with it as I knew it should work.

 

I can duplicate the fault and if I had the time I would log it with Microsoft, but to be honest after three days of shouting and swearing at PowerApps, I have given up the will for this particular issue.

 

So thank you @BCBuizer  for the assist and anyone else working through Incompatible Type then my advice is stick with it and check one thing at a time. Also, when you make a lot of definition changes to a variable then after you have saved it, open the app again, just to make sure it likes it.

Helpful resources

Announcements
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (1,506)