cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lumberjacklurch
Post Patron
Post Patron

Collection not filtering

I have a custom form that grabs records from a second list.   When the powerapp starts, I grab all of the records from this list, and put it in a collection (col_AllItems).  When a user clicks on an item in the primary list, I try to filter the col_AllItems collection by the ID of the selected item and put the results in a new collection (col_ItemView).  This was working fine until yesterday when I was troubleshooting a different issue with the form.  Below is the code, let me know if I inadvertently screwed something up.  I can't see that I did.  I need a different set of eyes on this, any help is appreciated.

 

OnSelect

ClearCollect(col_AllItems, SortByColumns('Sales Item List', "ID",Descending))

 

SharePointIntegrations -> OnView

Set(var_selectedRecord, SharePointIntegration.Selected);

ClearCollect(col_ItemView, ShowColumns(Filter(col_AllItems, var_selectedRecord.ID in 'Request ID'), "ItemName", "ItemDescription", "ItemQuantity"))

1 ACCEPTED SOLUTION

Accepted Solutions

OK, I figured out what was wrong with the filtering.  My OnView code was correct, but what I didn't remember/realize is I copied the code to the OnVisible property of the screen.  The OnVisible version had:

 

ClearCollect(col_ItemView, ShowColumns(Filter(col_AllItems, var_SharepointSelectedID in 'Request ID'), "ItemName", "ItemDescription", "ItemQuantity"))

 

Which of course I stopped using that variable for the filtering. 

 

Why I put the code in redundant locations, I can't remember.  I removed the code from the OnVisible property, and it's filtering fine.  HOWEVER, the problem of the collection not being visible upon the initial selection of a record still exists.  If you access a record via a list webpart (on a SPO home page), it doesn't show up at all.  I will open a new topic for this issue.  For now, I'll resolve this one.

View solution in original post

4 REPLIES 4
v-yutliu-msft
Community Support
Community Support

Hi @lumberjacklurch ,

Actually, I couldn't find any error in your formulas.

Could you tell me what did you do when you troubleshooted a different issue with the form?

I'm not sure whether the operation effects the collection.

Is ID and  'Request ID' the same data type?

Is 'Sales Item List' and this list not too large?

Please notice that since you set this formula in OnView, the collection will only be created when you view the custom form, not edit or add.

 

 

Best regards,

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yutliu-msft

Let me preface this reply with a description of an additional issue with this form.  Each item/request in the primary list has cooresponding item records in the secondary list.  When you view a request, the cooresponding item records should display in a gallery at the bottom of the customized form.  However, what's been happening when you click on a request is,  the form displays, but the gallery does not:

 

SSscreenshot1.png

 

I tried using a label, set it's Visible property to check if the variable wasn't empty.  It was fine.  I then set the Visible to check if the collection (col_ItemView) wasn't empty.  The label was visible, implying it wasn't empty, yet it doesn't show when you initially click on a request.  Now, if you click away/cancel the viewing of the form and click on the request again, it shows all of the items from the item list, not just the ones for the request you selected.

 

SSscreenshot3.png

This is what was originally happening when I opened this discussion yesterday.

 

After reading your reply, I checked, and the ID and 'Request ID' were not the same type.  'Request ID' was Single line of text.  I  changed it to Number.  After I refreshed, clicked on a request, the item list/gallery didn't show at all.  I changed it back.

 

The 'Sales Item List' is not large at all, it only has 4 records.

 

The only troubleshooting/code changes that I made was to break out the selected ID.  So instead of using var_selectedRecord.ID, I made a new variable called var_selectedRecordID and set it to SharePointIntegration.Selected.ID and put that in the ClearCollect line.  When that proved unhelpful, I changed it back, and here we are.

*BUMP*

OK, I figured out what was wrong with the filtering.  My OnView code was correct, but what I didn't remember/realize is I copied the code to the OnVisible property of the screen.  The OnVisible version had:

 

ClearCollect(col_ItemView, ShowColumns(Filter(col_AllItems, var_SharepointSelectedID in 'Request ID'), "ItemName", "ItemDescription", "ItemQuantity"))

 

Which of course I stopped using that variable for the filtering. 

 

Why I put the code in redundant locations, I can't remember.  I removed the code from the OnVisible property, and it's filtering fine.  HOWEVER, the problem of the collection not being visible upon the initial selection of a record still exists.  If you access a record via a list webpart (on a SPO home page), it doesn't show up at all.  I will open a new topic for this issue.  For now, I'll resolve this one.

View solution in original post

Helpful resources

Announcements
User Groups Public Preview

Join us for our User Group Public Preview!

Power Apps User Groups are coming! Make sure you’re among the first to know when user groups go live for public preview.

Power Apps Community Call

Monthly Power Apps Community Call

Did you miss the call?? Check out the Power Apps Community Call here!

Power Platform ISV STudio

Power Platform ISV Studio

ISV Studio is the go-to Power Platform destination for ISV’s to monitor & manage applications post-AppSource publish.

Top Solution Authors
Top Kudoed Authors
Users online (60,329)