cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
LeeB_CDN
Helper III
Helper III

Weird Variable bug in large PowerApp - Can't troubleshoot

 

Hello, PowerApps geniuses...

 

I am having an app crippling issue that appeared out of nowhere and I can't seem to solve it.  I have a global variable that is used throughout this app (mainly in all of the components and gallery buttons) called varCurrentItem that assigns the current row number from a gallery and then adds it to a collection referencing a Table variable called varMasterPPE (this used to be a collection variable but for performance reasons I recently changed it to a table variable). 

 

The app will work fine, with no issues then all of a sudden it will randomly flag ~ 3000 formulas with an "incompatible types for comparison error" centered around that varCurrentItem variable... which is set in this line of code (the on-select property of a button inside the gallery):

 

Set(varCurrentItem, ThisItem.RowNum);
ClearCollect(colCurrentItem, Filter(varMasterPPE, RowNum = varCurrentItem));

 

This is the code on the items property of the Gallery where the above code resides:

 

 

If(varUserInfoSearchTerm, Search(varUserInfoSearch, comAppAssignGallery.galAssignmentsSearchInput, "AdminName", "BranchInventory", "JobNumber",  "UserInfoName", "RepairLocation", "RepairReason"),

If(!varMainEditOpen,
Switch(
    varUserInfoFilterValue,
    "Assign Date", Sort(varUserInfoSearch, DateValue(DateTime), Ascending),
    "Branch", Sort(Filter(varUserInfoSearch, BranchInventory), Descending), 
    "HSE Admin", Sort(Filter(varUserInfoSearch, AdminName), Descending),
    "Job Number", Sort(Filter(varUserInfoSearch, JobNumber), Descending),
    "Name", Sort(Filter(varUserInfoSearch, UserInfoName), Descending), 
    "Repair", Sort(Filter(varUserInfoSearch, RepairStatus), Descending),
    "Return Date", Sort(varUserInfoSearch, DateValue(RepairReturnDate), Ascending), 
    "HSE Admin", Filter(Sort(varUserInfoSearch, AdminName, Descending), AdminName),
    "Supervisor", Filter(Sort(varUserInfoSearch, UserInfoManagerName, Ascending), UserInfoManagerName),
    "Vendor", Sort(Filter(varUserInfoSearch, RepairLocation), Descending),

varUserInfoDefault), 



LookUp(varMasterPPE, RowNum = varCurrentItem)

))

 

 

 

In the LookUp function it highlights the = sign and says "Incompatible type, can't compare number, error"  which seems to indicate varCurrentItem is in error? but as you can see from the snip below, varMasterPPE has a number in the RowNum Column...

 

LeeB_CDN_0-1667843893615.png

 

I have tried everything thinking the app is corrupted, backed up, downloaded and re-imported, reverted to earlier versions it will work for awhile and then for no reason spit out the errors again...

 

Hoping someone has some sort of insight for me??


Thanks in advance as always...

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
LeeB_CDN
Helper III
Helper III

@Drrickryp 

I finally found the issue... where varCurrentItem was contributing as an error (searching through it's variable definitions) I traced it to a separate gallery using the same onselect code in on buttons to select the current items that are stored in another global variable, which I had been setting as blank, all I had to do was populate that variable with data and the issue resolved itself.

Wow, that threw me for a loop! Definitely learned something today though!

Thanks for spending the time, appreciate your efforts!

View solution in original post

5 REPLIES 5
Drrickryp
Super User
Super User

@LeeB_CDN 

What happens if you try RowNum = Value(varCurrentItem)?

LeeB_CDN
Helper III
Helper III

@Drrickryp   Thanks for responding! Yeah, I thought it might just be a type mismatch with value, but that is not the case, as varCurrentItem is currently showing "error, no value", and when I add Value() it just says it's expecting a text or number

 

LeeB_CDN_0-1667850239634.png

 

But even if I set that variable to a value, it still seems to error out...

 

I am setting that global variable in multiple galleries on multiple buttons... Could that be an issue for some reason? Note: this is all being done in galleries that exist inside Components

Drrickryp
Super User
Super User

@LeeB_CDN 

Set(varCurrentItem,ThisItem) should work no matter where it is.  It will reset the variable whenever a new Item is selected in a gallery.  Make sure it is not referenced in an UpdateContext({...  Otherwise I don't know why it is doing that.

LeeB_CDN
Helper III
Helper III

@Drrickryp 

I finally found the issue... where varCurrentItem was contributing as an error (searching through it's variable definitions) I traced it to a separate gallery using the same onselect code in on buttons to select the current items that are stored in another global variable, which I had been setting as blank, all I had to do was populate that variable with data and the issue resolved itself.

Wow, that threw me for a loop! Definitely learned something today though!

Thanks for spending the time, appreciate your efforts!

Drrickryp
Super User
Super User

marty.jpg

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.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

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 (2,696)