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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Gallery Items property...
Power Apps
Unanswered

Gallery Items property Result issue; 0 row instead of 4!

(0) ShareShare
ReportReport
Posted on by 82

Hi,

 

I'm using Inspection App in msteams and I got an issue using a gallery and filter.

I put some screenshot in order to be more detailed.

 

Basically, I have entered an inspection with 8 steps. 4 of 8 are defined with the value "Issue" in the column "Outcome". So, when I click on my inspection in the screen "Review Inspection" I should see 4 rows in the gallery with outcome = 4 but the result is 0.

 

I tried to figure out and I don't understand.

 

Do you have an idea?

 

Dave

 

Categories:
I have the same question (0)
  • dsonier Profile Picture
    82 on at

    Here are my 3 others screenshots.

     

    Dave

  • dsonier Profile Picture
    82 on at

    I don't if it could help but I noticed some schema info about column Outcome in the table Area Inspection Steps.

     

    Dave

  • dsonier Profile Picture
    82 on at

    Here is another screenshots where I noticed the content of the table colSelectedInspection and all the values in the column "Outcome" are empty. Do you have idea?

     

    Dave

  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @dsonier ,

     

    There's too much info 😄

     

    Okay, can you let me know if you are switching screens to update or view the data?

    Since you have used UpdateContext variable and this only keeps data with respect to current screen. So when you move to another screen the data is lost. To keep data throughout the App, you can use Set() function to set Global variables.

     

    Also, can you simply state what is the issue and from which place data is coming and where are you updating it. I lost track in your images.

  • dsonier Profile Picture
    82 on at

    Hi @Ethan_R 

     

    I will try to simplify 🙂

     

    Microsoft Inspection app in MsTeams has 3 screens and in my case I refer only one screen called "Review Inspection". So, I don't switch the screen and it's probably the reason why the creator used the function UpdateContext.

     

    The source comes from a Dataverse table in Inspection App called "Area Inspection Steps" which one has the column "Outcome" that I refer in the filter function.

    dsonier_0-1707938532115.png

     

    The destination is datatype Table called "locSelectedInspection". See attachment.

    The code to update the destination table is this:

    UpdateContext(
    {locViewInspection: true,
    locSelectedInspection: Filter('Area Inspection Steps',
    Inspection.'Area Inspection' = ThisItem.'Area Inspection')}
    );

     

    In addition, I was also wondering why the columns are different between Dataverse Table and datatype Table. Does the behavior of the function Filter is different?

     

    Finally, what was the issue? Well, in a gallery when I use this formula below in the Items property the result is 0 using the filter. I assume it's normal because the filter is "Outcome = 'Inspection Outcome'.Issue" and in the table locSelectedInspection the column is there with empty value. Weird behavior.

    1. Source column name = Outcome

    dsonier_2-1707940151462.png

    2. Destination column name = msft_areainspection_outcomecode

    dsonier_1-1707939984243.png

     

    Code: 

    Sort(Filter(locSelectedInspection, Outcome = 'Inspection Outcome'.Issue
    ),Value(Sequence),SortOrder.Ascending)

     

    Thanks in advance,

    Dave

  • Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @dsonier ,

     

    Well, it is somewhat clear but still confused with the code. 

    Let me explain.

    This code which you have

    UpdateContext(
    {locViewInspection: true,
    locSelectedInspection: Filter('Area Inspection Steps',
    Inspection.'Area Inspection' = ThisItem.'Area Inspection')}
    );

    Does not update your Destination Table at all.

    This only filters records from your Source Table 'Area Inspection Steps' and stores in a context variable called 'locSelectedInspection'.

     

    Now, in order to make changes to Destination Table, you need to perform a Patch or UpdateIf operation on those filtered records in order to see updates to your Dataverse Table.

     

    I hope I understood this correctly 🙂

  • dsonier Profile Picture
    82 on at

    Hi @Ethan_R 

     

    Based on your answer: *Does not update your Destination Table at all.

    This only filters records from your Source Table 'Area Inspection Steps' and stores in a context variable called 'locSelectedInspection'.

     

    I agree. Maybe I didn't use the right words. I'm newer with PowerApps 😉 So, this code will store in context variable with 10 rows from the source table. My question here is why the source table and context variables don't have the same table structure including the columns names?

    Afterward, I use the result of the locSelectedInspection in a gallery always in the same screen to display the rows with Outcome = Issue and it's doesn't work.

    Here's the code:

    dsonier_0-1707941207380.png

     

    So, this is my situation that I don't understand the behavior.

     

    dsonier_1-1707941401045.png

     

    Dave

     

  • Verified answer
    Ethan_009 Profile Picture
    4,838 Moderator on at

    Hi @dsonier ,

     

    With respect to having different names, PowerApps get's names in 2 formats (Display Name and other is Logical Name) maybe all columns are not properly fetched in the App and it shows logical names. I might not know exact cause of this, but this won't give any issue. Always go with PowerApps suggested names when you type code and the prompt will be the one to go with always.

    Now, if any datatype is not matched or properly handled then the result return may be 0 or error.

     

    Let us check, Only try using filter portion in your Items property of Gallery.

    The 'Outcome' comparison should be of Choice only since it is the same datatype for better matching.

    Please note that you are using correct datasource (is it the one with variable or the actual Table name) 

     

    I will go though entire screenshots to check if I missed anything.

    Hope this helps

  • dsonier Profile Picture
    82 on at

    Hi @Ethan_R 

     

    In the first screen, I used this below using property Text of a Label. So, I use directly the table name 'Area Inspection Steps' and the count is correct. You can check the image 1.

    Text = "galItems.All:"
    & CountRows(Filter('Area Inspection Steps',
    Inspection.'Area Inspection' = ThisItem.'Area Inspection'))

     

    Screen 1:

    dsonier_0-1707946895265.png

     

    In the second screen, I used the gallery using the filter with Outcome and the result is correct for each line.

    CountRows(Filter(galInspection_Issues.AllItems,Outcome='Inspection Outcome'.Issue))

     

    Screen 2:

    dsonier_1-1707946926230.png

     

    In short, I assume that my issue is related to the context variable colSelectedInspection which one hasn't the same table structure then original dataverse table and that the data seems not be updated. I will try to figure out something else. It's just weird that it's the original sourcecode that I downloaded from MSTeams App section.

     

    Thanks,

     

    Dave

     

    ==================================

    BTW, I find this on ChatGPT. Maybe that could help. But I think I use the right function as Set and UpdateContext.

    ==================================

    In PowerApps, if you want to store the data from a Dataverse table in a context variable, you can follow these general steps. Keep in mind that the process might vary based on the specifics of your app and the data structure. Here's a basic example:

    1. **Create a Context Variable:**
    - Start by creating a context variable. You can do this in the OnStart property of the app or in a specific screen. For example, if you want to create a context variable in the OnStart property, go to the App object, and in the "OnStart" property, add the following code:

    ```PowerApps
    Set(varMyData, YourDataverseTableName)
    ```

    Replace `varMyData` with the name you want to give to your context variable, and `YourDataverseTableName` with the actual name of your Dataverse table.

    2. **Load Data into the Context Variable:**
    - You'll need to load the data from the Dataverse table into the context variable. You can use functions like `ClearCollect` or `Filter` to achieve this.

    ```PowerApps
    ClearCollect(varMyData, YourDataverseTable)
    ```

    Replace `YourDataverseTable` with the actual name of your Dataverse table.

    3. **Use the Context Variable:**
    - Now that your data is stored in the context variable, you can use it throughout your app. For example, you can set the Items property of a gallery to display the data:

    ```PowerApps
    Gallery1.Items = varMyData
    ```

    4. **Update Context Variable as Needed:**
    - If you need to update the data in the context variable (for example, if the Dataverse table is updated), you can use the same approach to refresh or update the context variable.

    ```PowerApps
    ClearCollect(varMyData, YourDataverseTable)
    ```

    This will replace the existing data in the context variable with the updated data from the Dataverse table.

    Remember to replace placeholders like `varMyData` and `YourDataverseTable` with your actual variable name and Dataverse table name.

    Please note that the specific syntax and steps might vary based on your app's structure and requirements. If you encounter issues or need more specific guidance, feel free to provide more details about your app, and I can offer more tailored assistance.

    ================================================

  • dsonier Profile Picture
    82 on at

    Hi @Ethan_R 

     

    Did you find something new on your side?

    I will continue my testing this week to see if I get an issue since I replace the Context Variable by Dataverse table. I just weird that the original code from Microsoft doesn't work.

     

    A+

     

    Dave

     

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard