Icon has different color depending on data

Been stuck on this issue for a bit now if anyone could provide any insights :slightly_smiling_face:

I have a bookmark icon nested in a repeating group of jobs. I want the bookmark icon to have a different color on page load, depending on if the user has this specific job saved in the database.

  • repeating group job
    • group job
      • Icon fa fa-bookmark-o

So my issue is, I am not sure how to implement this. When the page loads, I want specific bookmark icons on specific cells of the repeating group to be colored, depending on if the current cell job is one of the current user’s saved jobs.

So far, I’ve tried creating a conditional on the bookmark icon, but the logic doesn’t work. What I was trying to do is Search from my database Saved Jobs, with the constraint being that the Created By is the current user(this is where I connect the saved job to the current user) contains this current parent group’s job. I think I’m doing this incorrectly. Are we able to do this on an icon conditional?
screenshot

I’ve also attempted to do it manually on the workflow but to no success. I found that I can only access the bookmark icon if I navigated the start/edit workflow from the icon itself, but I can only modify what happens when the bookmark is clicked.

I already have an implementation of the bookmark changing color when it is added/removed to the Saved Jobs database, but it doesn’t show the color change when the specific job is already saved in the database. By default, all of the bookmark icons are uncolored. I also can’t access the bookmark icon directly from the workflow, and I’m thinking it may be because the icon is nested in the repeating group. Any ideas on how I can do this? Any help is appreciated!

Hi there, @supportportal… if I remember correctly from your first post and if I understand this post correctly, try changing the expression in your screenshot to Search for Saved Jobs:count > 0, and add another constraint to the search where the saved job’s job is the parent group’s job.

By the way… and just some food for thought here… if a user isn’t going to have a lot of saved jobs, you could probably simplify this whole thing by having a saved jobs field (which would be a list of jobs, of course) on the User data type. That would eliminate the need to do a search for saved jobs, and the expression would simply be when Current User's saved jobs contains Parent group's Job. Again, just food for thought.

Hope this helps.

Best…
Mike

1 Like

It worked! Thanks @mikeloc! I’ve tried it but nothing happened at first. I deleted the entire conditional, created it again, refreshed the page, and then it worked! Seems like Bubble is a bit buggy.

I was struggling with this for a couple days now and you just helped me solve this issue. Appreciate the help!

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.