web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Need Help with OnSelec...
Power Apps
Unanswered

Need Help with OnSelect Logic for Canvas App

(0) ShareShare
ReportReport
Posted on by 4

Greetings!  I have a PowerApps Canvas App that I am bolting onto a Power BI Dashboard.  The goal of this app is to do a mass update of two fields in a MySQL table based on two dropdown values (ddNewStatus_1.Selected.id and ddNewUse_1.SelectedID).  My Canvas App as a Gallery1 with these fields:  Egg_ID (the ID), Use, Status, and Description.  The MySQL table (mysql.mytable) has many fields in it.  It has a primary key of ID and contains two columns called Status and Use (along with quite a few more columns).  The use case is that a user filters the data set in Power BI and it in turn passes the selected mysql.mytable.ID (along with Status, Use and Description) values to my Canvas App that get deposited into Gallery1.  The user can choose each dropdown value and hit submit (no record selection as all records brought into the Gallery1 will be updated).

 

Here is my OnSelect logic.  It's getting hung-up on the Lookup on my patch: "Issue - Incompatible types for comparison.  These types can't be compared:  Number, Control".

 

OnSelect:

ClearCollect(
  UpdateCol,
  ForAll(
    Gallery1.AllItems,
    {
      EID: ThisRecord.Egg_ID
    }
  )
);
ForAll (UpdateCol,
  Patch (
  'mysql.mytable',
  LookUp('mysql.mytable',ID=EID),
  {
    Status: ddNewStatus_1.Selected.ID,
    Use: ddNewUse_1.Selected.ID

  } )

);

Categories:
  • Rusk Profile Picture
    1,369 Super User 2024 Season 1 on at

    Hi @Poopdeck90210 

     

    It looks like you are only updating your collection with EID: ThisRecord.Egg_ID in your first formula.  Then, you reference this EID value in your second formula.

     

    What is your intent of breaking this out into two updates?  It looks a little weird

  • Poopdeck90210 Profile Picture
    4 on at

    Greetings!

     

    My intent is to create a collection of ID's (labeled EID in my collection UpdateCol) from the Gallery1 in my Power Apps Canvas App and then loop thru (ForAll w/Lookup) that gallery of ID's and update the matching records in mysql.mytable (ID=EID) and for each match, set mysql.mytable.Status = the status number selected in the dropdown in my Power Apps Canvas App and set mysql.mytable.Use = the use number selected in the dropdown in my Power Apps Canvas App.  Here is a visual of the Power Apps Canvas App I wrote which is embedded in a PowerBi Dashboard and is powered by MySQL underneath (using a MariaDB ODBC connection so I can do a dynamic refresh of my PowerBI Dashboard).

    Power Apps Canvas App Sanitized Example 01.png

  • Rusk Profile Picture
    1,369 Super User 2024 Season 1 on at

    I guess I still don't understand the need to collect those values and then patch that collection... what happens if you just patch the selected gallery items?  Does it still have an "Incompatible types" error?

     

    ForAll (Gallery1.AllItems,
     Patch (
     'mysql.mytable',
     LookUp('mysql.mytable',ID=ThisRecord.Egg_ID),
     {
     Status: ddNewStatus_1.Selected.ID,
     Use: ddNewUse_1.Selected.ID
    
     } )

     

  • Poopdeck90210 Profile Picture
    4 on at

    Thank you.  I tried this and it's throwing two errors: 

    1) Name isn't valid.  'Egg_ID' isn't recognized.

    2) Incompatible type for comparison.  These types can't be compared:  Number, Error

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard