Need help filtering a formula

Hi, I have an array called ‘meditationInteractions’. One of the fields is a ‘meditation_id’. I also have a variable called ‘currentAudio’ which holds an object that also has an id. What I’m trying to do is find the id of the ‘meditationInteraction’ object record, where its ‘meditation_id’ matches the ‘currentaudio’ ID.

I have a split in Weweb that searches to see if a record exists. If it is false, it creates the record. That part is setup and working.

What I’m using this formula for is when the record is true, but I need the id so I know what record to update in Xano.

Normally I’d use Copilot for this but its rate limit is exceeded at the moment.

Hey Mark, why don’t you use the GetKeyValue formula to extract out the meditation_id from the object?

Hi, I tried, but I’m not sure how to get it the formula to work correctly to get the result I want.

Maybe you can show screenshots of what you’ve got so far and where the problem is…

Actually, I figured it out but I have a new one I’m struggling with thats a little similar.

It’s a simple favourite button that allows people to add their mark episodes as favourites.

In the picture below I believe I’ve figured out a way to display the element only if there is a meditationInteraction object that has the same meditation_id as the current items meditation_id.

What I actually want to do is only display it if the meditationInteractions ‘favourite’ record is false, as well as If there is no meditationinteraction record for this collection Item.

I already have the workflows that add and remove it from favorites setup and working, its just the displaying the icon that triggers those workflows thats giving me trouble.

Edit:

You should probably use lookup

lookup(item.data.id ,meditationInteractions, "id")

this will return the object of the matching meditationInteractions. Keep in mind that if there isnt a meditationInteraction matching it will return undefined

After this if you want to see the value of favourite you can do

lookup(item.data.id ,meditationInteractions, "id").favourite
1 Like

Thanks! This works, and everytime you guy show me something like this it helps me understand the formulas better for future use cases, so I really appreciate your help.

I’m sure I can just use 3 different icons and display them conditionally. 1 if there are no interaction records at all, 1 if there is and the Favourite is false and another if its true.