cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Daemetius
Helper II
Helper II

Error: Cannot use record values in this context

Hello, 

 

I have an issue where I've been stuck for weeks and hoping to see if someone can help or had this before.

 

So I am trying to create a comments gallery within a parent record. E.g: A comment section from an idea posted by a user. 

 

The filter function I was told is good to use since I have lookup fields in my sharepoint lists used as data sources. 

 

Filter(Comments, IdeasGallery.Selected.ID in TargetID) but I get an error under "TargetID" saying "Invalid argument type. Cannot use record values in this context"

 

To get a better picture of what I'm trying to do. 

 

I have a Sharepoint list called "Ideas" and another list called "Comments". I created two lookup fields in the Comment's list called TargetID and TargetID: Subject.

 

TargetID points to the ID field in the "Ideas" sharepoint list showing the corresponding ID while the TargetID: Subject field shows the corresponding title of the Idea. 

 

So I have:

 

The Ideas Sharepoint List

Ideas List.png

 

The Comments Sharepoint List

 

Comments List.png

The Comments list shows the TargetID: Subject, which is the subject that is tied to the TargetID. The TargetID is the ID taken from the Ideas Sharepoint list. 

 

What I am looking for is that for example in the comments list, the TargetID, 16 is repeated and has different comments for the same idea. I need to filter it in the PowerApps gallery so that only the comments for that idea are only shown.

 

Any help is greatly appreciated.

 

13 REPLIES 13


@Anonymous wrote:

Did it produce the same error? Note that Value is not a function unlike previously suggested, but a property now.

 

TargetID seems to be a record. If you enter a period (.) after TargetID, there should be some suggestions. Some of those would be the actual fields of the record. If there are, what are they?

 

And I'm gonna take a wild guess and have you try this:

Filter(Comments, TargetID.ID = IdeasGallery.Selected.ID)

 

 


 

The following code you offered also didn't give errors, but the Comments Gallery is empty. It's something at least. Now Gotta see if I have to change the labels so they show  the comments. 

Anonymous
Not applicable

At least we got the syntax right. Silver lining. Lol.

 

So, I think there are a couple of possibilities: 

  1. The Filter() is taking some time to load and in the meanwhile, we're getting an empty collection -- meaning it just needs time.
  2. The condition actually evaluates to false for every record meaning our condition, while syntatically correct, is semantically wrong.
  3. You haven't selected a record from the Ideas gallery (unlikely). I don't know whether the left-part of the screen is a gallery or not. If you haven't clicked on anything yet, then IdeasGallery.Selected would be empty. (Ref?)
  4. The references inside the comments gallery are invalid and the yellow warning signs are hiding (it happened to me).

 

If you don't mind (I'm actually enjoying this), we could try to debug things (the amateur way, lol)! Try the following things and let me know what you see. (In case you do mind, feel free to ignore me.)

  1. Set the condition in the comments gallery to true. i.e. 
    Filter( Comments, true )
    This should make all the comments, regardless of Parent Idea, to appear. If this is still blank, then Possibility (1) or Possibiility (4) may be the reason. If all records appear, then something is wrong with our condition and revert changes.
  2. Make a label and set Text to IdeasGallery.Selected.ID. Just to know what the actual value is. If it displays nothing, then Possibility (3) may be the reason. If not, there might be something wrong with the Filter() expression.
  3. Try deliberately making the filter condition true for selected rows. For example, do this:
    Filter( Comments, TargetID.Value = 16 )
    Note: I'm not sure of the data types so... If Ideas.ID is a string, replace 16 with "16". 
    This should make some records appear. If not, TargetID.Value is the culprit here.

 

Let me know what these actions do and we'll go from there (if you still want to, that is). 😄


@Anonymous wrote:

At least we got the syntax right. Silver lining. Lol.

 

So, I think there are a couple of possibilities: 

  1. The Filter() is taking some time to load and in the meanwhile, we're getting an empty collection -- meaning it just needs time.
  2. The condition actually evaluates to false for every record meaning our condition, while syntatically correct, is semantically wrong.
  3. You haven't selected a record from the Ideas gallery (unlikely). I don't know whether the left-part of the screen is a gallery or not. If you haven't clicked on anything yet, then IdeasGallery.Selected would be empty. (Ref?)
  4. The references inside the comments gallery are invalid and the yellow warning signs are hiding (it happened to me).

 

If you don't mind (I'm actually enjoying this), we could try to debug things (the amateur way, lol)! Try the following things and let me know what you see. (In case you do mind, feel free to ignore me.)

  1. Set the condition in the comments gallery to true. i.e. 
    Filter( Comments, true )
    This should make all the comments, regardless of Parent Idea, to appear. If this is still blank, then Possibility (1) or Possibiility (4) may be the reason. If all records appear, then something is wrong with our condition and revert changes.
  2. Make a label and set Text to IdeasGallery.Selected.ID. Just to know what the actual value is. If it displays nothing, then Possibility (3) may be the reason. If not, there might be something wrong with the Filter() expression.
  3. Try deliberately making the filter condition true for selected rows. For example, do this:
    Filter( Comments, TargetID.Value = 16 )
    Note: I'm not sure of the data types so... If Ideas.ID is a string, replace 16 with "16". 
    This should make some records appear. If not, TargetID.Value is the culprit here.

 

Let me know what these actions do and we'll go from there (if you still want to, that is). 😄


 

 

Filter(Comments, TargetID.Id = IdeasGallery.Selected.ID)

This code helped! Thank bro! The comments appear for their respective ideas. It was the label that was set to ThisItem.AssetID and not ThisItem.Comments. At least it works for now, I have to keep trying and see. I will take your other suggestions into consideration though!

 

Here is how it looks. 

 

comments.PNG

 

If I wanted to add another field besides comments, for example "Authors" field to the gallery would I need to add && to the filter function? 

Anonymous
Not applicable

Yeah!

 

For my other suggestions, they're for debugging purposes. If it works, then there's no need to do them. PA doesn't really give you good feedback when it comes to errors (syntax or otherwise), so we usually have to narrow the error down into a specific point.

 

But for another field? You would have to add that first to the Comments list, which I assume you already do know.

So, unless you have to filter by author AND by idea, there's no reason to add another condition in the Filter() function. If you just want to display another field like Author, then just create another label in the template of the comments gallery and reference that thing in the Text property of that label.

 

And no problem, dude. It was fun for me. 

 

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza Winner Announcement

Please join us on Wednesday, July 21st at 8a PDT. We will be announcing the Winners of the Demo Extravaganza!

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,587)