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 / Patched SharePoint ite...
Power Apps
Answered

Patched SharePoint items from a collection aren't filtering correctly afterwards

(0) ShareShare
ReportReport
Posted on by 58
I'm stumped on this. I have a SharePoint list (dStudentSchedule ) I'm patching records to, but some records items in a text column 'Teacher' aren't being treated as text. When I load/filter the dStudentSchedule list into a gallery using Filter(dStudentsSchedule, Teacher = varUser), some of the records aren't showing up. When writing records to the dStudentSchedule list I have two Patches occuring, and the records from the 2nd Patch are the ones not filtering correctly.
 
Here is my setup. The two seperate Patches occuer on a button OnSelect
 
First Patch: Patching from lables and text inputs - Patch(dStudentSchedule, Defaults(dStudentsSchedule), { Title: "1819", Teacher: varUser, StudentName: lblNewStudentName.Text, Grade: txtNewStudentGrade.Text, Period: txtNewStudentPeriod.Text, OnContractWithTeacher: true, TeacherConfirmation: true, DateOnContract: dtpNewStudentDate.SelectedDate, Comments: txtNewStudentComments.Text});
 
varUser is already set to User().Fullname, and the 'Teacher' column in my SharePoint list is formatted for "single line of text". Everything works as expected, but my 2nd Patch is where I'm finding issues.
 
2nd Patch: Patching 5 records from a collection made up of the collection items and some of the same information from the first patch - ForAll(NewStudentSchedule, Patch(dStudentsSchedule, { Title: "1819", Teacher: Teacher, StudentName: lblNewStudentName.Text, Grade: txtNewStudentGrade.Text, Period: Period, OnContractWithTeacher: false, TeacherConfirmation: false }));
 
The collection (NewStudentSchedule) is made up of two items, Period and Teacher, and is created through two dropdown selections. User selects a item from drpPeriod ["1", "2", "3", "4", "5", "6", "7"] and also an item from a dropdown of teacher names ["Andrew Fitzgerald", "Teacher B", "Teacher C", etc.]. After the user has selected these two items, they press a button which adds the two values to the collection (NewStudentSchedule).
Button OnSelect --> Collect(NewStudentSchedule, { Period: drpNewStudentPeriod.Selected.Value, Teacher: drpNewStudentTeacher.Selected.Value})
 
So, when the 2nd Patch goes into effect, everything looks like it worked. On the SharePoint list (dStudentSchedule), the first record gets patched, and then the 5 records from the 2nd patch show up. 6 records total. But, I'm having trouble filtering the list by the 'Teacher' column afterwards. In my PowerApp, I have a gallery and data table showing my dStudentSchedule list. When I use Filter(dStudentsSchedule, Teacher = User().Fullname) or Filter(dStudentsSchedule, Teacher = varUser), or Filter(dStudentsSchedule, Teacher = "Andrew Fitzgerald"), I'm not seeing any records from the 2nd Patch from the NewStudentSchedule collection.
 
For example, if this is my sharepoint list dStudentSchedule:
 

From Patch

Teacher

Student

Period

1st Patch

Andrew Fitzgerald

Johnny Bravo

4

2nd Patch

Teacher B

Johnny Bravo

1

2nd Patch

Teacher C

Johnny Bravo

2

2nd Patch

Teacher D

Johnny Bravo

3

2nd Patch

Teacher E

Johnny Bravo

6

2nd Patch

Andrew Fitzgerald

Johnny Bravo

7

 
If User().FullName or varUser is me (Andrew Fitzgerald), all I get from my filter is the first record from the 1st Patch and not the last record from the 2nd Patch.
 
What I've tried: I've tried throwing a Text() around everything associated with the 'Teacher' column; varUser,  User().FullName, the Teacher dropdown list, and the Teacher values in the 2nd Patch function. I've also put the collection in a gallery and tried patching the lable boxes in the gallery. Nothing works, the list never filters properly.
 
What does work: 

ForAll(NewStudentSchedule, Patch(dStudentsSchedule, { Title: "1819", Teacher: "Andrew Fitzgerald", StudentName: lblNewStudentName.Text, Grade: txtNewStudentGrade.Text, Period: Period, OnContractWithTeacher: false, TeacherConfirmation: false }))

But in this case, all records will have "Andrew Fitzgerald" in the teacher column, and that's not what I'm looking for. 

I feel like the SharePoint list is not treating the 'Teacher' values from the 2nd Patch as text, and somehow it's related to my Teacher Dropdown control, but at this point I have no idea how to fix this. 

Anybody know what I'm doing wrong?
 
Categories:
  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    Is there a reason you aren't using "Defaults(dStudentsSchedule)" as the second parameter on the 2nd Patch()? I have seen some flaky things happen with SharePoint when I don't use the Defaults() as the second parameter in Patch() when creating a new item.

  • AndrewFitz Profile Picture
    58 on at

    @Jeff_ThorpeI must have deleted that with all my messing around trying to find a solution. I put the Defaults() back in there and it still does not work

  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    Since you have a field name "Teacher" in both NewStudentSchedule and dStudentsSchedule lets run a simple test to make sure that isn't part of the issue. I made slight change to the formula to rename the teacher column.

    ForAll(RenameColumns(NewStudentSchedule, "Teacher" ,"TeacherName"), Patch(dStudentsSchedule, Defaults(dStudentsSchedule), { Title: "1819", Teacher: TeacherName, StudentName: lblNewStudentName.Text, Grade: txtNewStudentGrade.Text, Period: Period, OnContractWithTeacher: false, TeacherConfirmation: false }))

  • AndrewFitz Profile Picture
    58 on at

    Unfortunately that didn't work @Jeff_Thorpe 

     

    As a side note, if I edit the 'Teacher' column in a record from the 2nd Patch on the dStudentSchedule SharePoint list, for instance deleting the original "Andrew Fitzgerald" text and then typing out "Andrew Fitzgerald" and saving.....that fixes the record and the record shows up in the filter. 

  • Jeff_Thorpe Profile Picture
    6,085 Super User 2024 Season 1 on at

    This issue sounds very weird and now I am grasping at straws.

     

    Before you deleted out the teacher name in the SharePoint list did you examine it carefully to make sure there were no extra spaces or characters? Also have you try refreshing the Data Source after the update? 

    If you go to View > Collections in PowerApps and look at the NewStudentSchedule collection does the Teacher column show the text value or does it show the record icon and you have to click on that to see the value?

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @AndrewFitz & @Jeff_Thorpe 

    Looking for another straw??

    You might also try to look back at the DropDown items.  As a test, try to change your items to  [User().FullName, "Teacher B", "Teacher C", etc.]

    This should give a direct entry of the same text in the dropdown that you are storing and expecting to filter later.

    That *should* eliminate text dissimilarities.

    Thought I'd toss in a straw!

     

  • AndrewFitz Profile Picture
    58 on at

    View --> Collections --> NewStudentSchedule shows the text value

     

    On the SharePoint list 'Teacher' column, there are no extra spaces or characters....but...

     

    Lets the say the bad record has the 'Teacher' item as "Andrew Fitzgerald". If I edit the record in SharePoint and

     

     -  Delete "Fitzgerald" and then retype "Fitzgerald", the record still doesn't work

     -  Delete " Fitzgerald" (I also delete the space) and then retype " Fitzgerald", the record works!

     

    That space is screwing everything up. The text originates from my Teacher dropdown. and......I figured it out. Posting my error next

  • Verified answer
    AndrewFitz Profile Picture
    58 on at

    First off, thank you @Jeff_Thorpe and @RandyHayes for chiming in. You guys led me to my ah-ha! (and facepalm) moment. I retraced my steps making this app and figured out the issue. It was the space " " in the Teacher dropdown items. When getting my teacher names, I had copy/pasted the names from the address field of an Outlook email. Even though it looked like a regular space, that character must have been something else instead in disguise. I went back to my dropdown list items, deleted and retyped the space " ", and now my filter works. 

     

    Thank you again!

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @AndrewFitz 

    Ah, hard-coding strikes again!!  You might want to consider putting your teacher names into another list, then use that list for your DropDown source, filters, etc.  That way you never run into a text dissimilarity.

    Don't hit that face-plant too hard! Smiley LOL

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

#2
WarrenBelz Profile Picture

WarrenBelz 190 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard