Weird behavior filtering on repeated card component

I’ve got a set of different card components populated by a data resource and filtered by categories. At the top, I have a recommended card component that is based on the user’s interest and filtered based on a page variable.

In the new runtime, it does not automatically populate the recommended section. Prior to the runtime update, it worked just fine. In the new runtime, if I put that exact same filtering logic in one of the category cards the logic works just fine. Thus it is not the logic itself but something else.

I can’t seem to figure out how to get it to populate. I’ve tried a delay node for showing the component on page mount & focus which worked at first but no longer works. I’m pulling my hair out trying to figure out how to get the recommended card to display.

Any ideas as to how to rectify this issue?

Hi William! Do I understand correctly that both the recommended and the category take from the same data resource and use SELECT to narrow down the dataset, only in the recommended section this happens based on a page variable? It would be helpful if you could post the formulas that you are using, so we can try to replicate the issue and find out what’s going on here. :slight_smile:

1 Like

Yes, you are correct that they are same data resource, but I am not using SELECT. I am filtering on the visibility parameter with the following formula:

CONTAINS(pageVars.recommendedTopic, current.fields.interest1) || CONTAINS(pageVars.recommendedTopic, current.fields.milestone1) || CONTAINS(pageVars.recommendedTopic, current.fields.type)

Then in the other repeated categories, I am filtering using the visible parameter but name the specific category:

CONTAINS(current.fields.type, “Savings”)

Perhaps that is the issue is that I should be filtering at the repeated resource parameter vs. the visibility parameter?

The new runtimes do not evaluate formulas in the Visible property of a repeated component - they just result in False now. I verified this as a bug few weeks ago and it is supposedly being worked on.

Hey @JOHN_WORSHAM, for the most part these fixes should have gone live in the last release (2.4.33) but if there is still some current visibility bugs, could you point me to those :slight_smile: Thanks!

Yes it works now. Thanks

Thanks @JOHN_WORSHAM and @Mari

It appears moving to the repeated with parameter vs. the visible parameter using a SELECT function with the same CONTAINS logic (except replacing “current.” to “item.” has resolved the issue. Here’s the formula for those who want to mimic what I did:

SELECT(data.RESOURCETOREPEAT, CONTAINS(pageVars.recommendedTopic, item.fields.milestone1))

2 Likes

It appears this is broken again and no longer filtering properly. I haven’t touched the page that has this logic so unsure what caused the issue.

Is this the formula you are using? What type are the variables? Which version of the preview app are you testing on (found by clicking your username)?

Thanks @Mari I am using 2.5.3 in the preview app but the problem persists on the standalone build on both using the 2.4.35 or the 2.5.10.

Yes, that is the formula I am using combined with some additional OR statements that checks other fields in the repeated data set similar to item.fileds.milestone1.

To take a step back, as I’m likely overcomplicating this

  1. I have two app variables that have a list of texts which is what I want to use to filter my repeated resource.

2, I couldn’t figure out how to directly parse a list of texts so upon page mounting, I set the pageVars.recommended topic with the following formula:

JOIN(appVars.currentUser.metadata.milestones, “,”) + “,” + JOIN(appVars.currentUser.metadata.interests, “,”)

  1. From there, I then use the formula you referenced on the repeated resource:

SELECT(data.ChallengesList,CONTAINS(pageVars.recommendedTopic, item.fields.milestone1)) ||SELECT(data.ChallengesList,CONTAINS(pageVars.recommendedTopic, item.fields.interest1)) || SELECT(data.ChallengesList,CONTAINS(pageVars.recommendedTopic, item.fields.type))

My thought is I may be trying to do too much and there is a simpler way to apply the filtering logic directly to the list of texts in my app variable. The above was working previously though.

The JOIN approach works, although what you are doing is you’re basically converting your lists of texts into a string. It could be better to stick with the list format – adding stuff into a string is easy, getting them out is a bit harder. :smile:

First you could use UNION to join the lists into one, and then IS_IN_ARRAY instead of CONTAINS to find individual items in there. So

UNION(appVars.currentUser.metadata.milestones, appVars.currentUser.metadata.interests)

SELECT(data.ChallengesList, IS_IN_ARRAY(pageVars.recommendedTopic, item.fields.milestone1))

I get confused with the OR formulas though, and think that’s probably the issue here. Can you explain what are you trying to achieve with that final formula?

1 Like

Thanks @Mari

That seems to have fixed the issue. The OR formulas were because I want to check the data against multiple fields in the data resource. Wasn’t sure the best way to do that piece either.

Comparing lists with OR will give you the first one that is not empty, which is probably not the functionality that you want:

Instead, you could choose those items whose milestone1, interest1 or type can be found in recommendedTopic in the SELECT formula:

SELECT(data.ChallengesList, IS_IN_ARRAY(pageVars.recommendedTopic, item.fields.milestone1) || IS_IN_ARRAY(pageVars.recommendedTopic, item.fields.interest1) || IS_IN_ARRAY(pageVars.recommendedTopic, item.fields.type))

1 Like

Thanks for sharing! Yes that is what I wanted. Didn’t realize what I had written would stop after the first result.

2 Likes