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 / Runtime error "DBnull"...
Power Apps
Answered

Runtime error "DBnull" on gallery

(0) ShareShare
ReportReport
Posted on by 44

Hi all,

 

I've recently came across an issue related to two of my galleries. I don't know why this happens now as it didn't do it before.

When I edit or play my app i see runtime issues within the "App checker". My gallery is marked with an error and displays the following errormessage:

"The requested operation is invalid. Server response <table/datasource> failed: Type 'System.DBNull" with data contract name 'DBNull.........' is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not know statistically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding tem to the list of known types passed to the serializer."

I have a combobox and a searchbox from which i filter my gallery from and if i choose a value within the combobox - the error of the gallery dissappears and results are listed in the gallery.
Also, in edit mode - when i adjust the items formula of the gallery, for example removing and adding the last paranthesis - the error also dissappears. 

What is annoying is that users of the app will get this error message until they choose a value within the combobox. 

I have an idea that might work, it's to not filter any results within the gallery if my combobox is blank but I am unsure of how to do that. I assume I need to use some type if !IsBlank here. The items formula for the gallery is currently:

Search(Filter('DATASOURCE','Model number' in COMBOBOX.SelectedItems),TEXTSEARCHBOX.Text,"TEXTCOLUMN IN DATA SOURCE")
 
Thanks in advance, appriciate any help!

Categories:
  • Verified answer
    iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    So its when its trying to do an 'in' filter for something that doesn't exist yet. You can tweak your code as follows to not filter by that when its not selected yet by checking the number of selected rows in the combobox:

    Search(
     Filter('DATASOURCE',
     CountRows(COMBOBOX.SelectedItems)=0
     ||
     'Model number' in COMBOBOX.SelectedItems
     ),
     TEXTSEARCHBOX.Text,
     "TEXTCOLUMN IN DATA SOURCE"
    )

     

    Cheers,

    Sancho

  • AndLun Profile Picture
    44 on at

    Hi Sancho,

     

    Thanks for your awnser. I guess that would work aswell however I just did manage to solve it by doing as below. Would there be any difference between your solution or the one below?

    If(!IsBlank(ModelComboBox),Search(Filter('DATASOURCE','Model number' in COMBOBOX.SelectedItems),TEXTSEARCHBOX.Text,"TEXTCOLUMN IN DATA SOURCE"))

    Also, asking about this I have another question that maybe you can help me with. When getting the results in the gallery, I recieve multiple results of the same "ID" in my gallery (this is because I have not yet populated anything in my searchbox). However, I would like the gallery only to display distinct values when I have only populated the modelcombobox already and not the searchbox yet. I've tried with some kind of distinct function but cant get it to work. My "ID value" exists multiple time within the datasource.

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 405 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 368

#3
WarrenBelz Profile Picture

WarrenBelz 244 Most Valuable Professional

Last 30 days Overall leaderboard