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 / check if a gallery has...
Power Apps
Answered

check if a gallery has data

(0) ShareShare
ReportReport
Posted on by

HI All,

I have a barcode scanner on my app, after I scan, I load a variable, to hold the barcode.  I have a gallery that will pull the data from my SPO list that matches the Barcode.  

Is there a way to check if the barcode exists?  I would like to popup a message "Bar Not Found".

I have an HTML text box that is visible when "VarshowEmptyBar" = true

 

The "On Scan" property is set to:

Set(VarBarcode, BarcodeScanner2.Value);  // gallery Items are based on this variable...

If(CountRows(BrowseGallery_Lookup.AllItems) = 0, UpdateContext({VarshowEmptyBar:true}),UpdateContext({VarshowEmptyBar:false}))

 

I am having an issue, when I scan, I get the message pop up, regardless of weather the barcode is there or not.  If the bar exists, the data comes back, but so does the popup. 

 

Does anyone know how to avoid the popup if there is a match? 

It almost seems like I need a delay after I scan.  The check seems to fire off before the data comes back.

 

Thanks,

Joe

Categories:
I have the same question (0)
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    I created a test using your code that is working. What is the Items property of your gallery set to?

  • joef Profile Picture
    on at

    HI @Anonymous,

    That's weird, Every time I do the first scan I get the popup, then the data comes thru a second later..

     

    My gallery Items are set to:

    Filter('Mail Room APP', (Barcode=VarBarcode))

     

    Thanks,

    Joe

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Try using this in your OnSelect

    Set(VarBarcode, BarcodeScanner2.Value);
    If(CountRows(Filter('Mail Room APP', (Barcode=VarBarcode))) = 0, UpdateContext({VarshowEmptyBar:true}),UpdateContext({VarshowEmptyBar:false}))

     

  • joef Profile Picture
    on at

    Thank you @Anonymous ...

     

    That was it, but I am getting a delegation warning..  Is there a way to get rid of that?

     

    Joe

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Try using Lookup() instead of Filter() in the OnScan property. Since you're using CountRows() all you care about is if there is 0 or more than 0. Lookup() will only return one row, so CountRows() will either equal 0 or 1.

  • joef Profile Picture
    on at

    Hi @Anonymous ,

    this causes an error

     

    Set(VarBarcode, BarcodeScanner2.Value); If(CountRows(Lookup('Mail Room APP', (Barcode=VarBarcode))) = 0, UpdateContext({VarshowEmptyBar:true}),UpdateContext({VarshowEmptyBar:false}))

     

    CountRows has some invalid arguments...

     

    Joe

  • Verified answer
    Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Try this

    Set(VarBarcode, BarcodeScanner2.Value);
    If(CountRows(Lookup('Mail Room APP', (Barcode=VarBarcode)).Barcode) = 0, UpdateContext({VarshowEmptyBar:true}),UpdateContext({VarshowEmptyBar:false}))
  • joef Profile Picture
    on at

    hi @Anonymous ,

    I added the .Barcode to the Filter and all is good no more delegation warning, and it works perfectly!!

     

    The lookup kept giving me the same error about CountRows having invalid parameters.

     

    Thanks Again!!

     

    Joe

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 358 Most Valuable Professional

#2
11manish Profile Picture

11manish 214 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 185

Last 30 days Overall leaderboard