Changing Background Color Based on State Content

I have created a repeating group toggle-type menu that sets a state (called Genre Button) based on the app data source (Genre) for the repeating group. I am wanting to change the background color based on the state’s specific content, but am not able to enter that into the conditional formatting.

I want to say when [pagename]'s Genre Button is Action (action is one of the items in the Genre data)… but when I type action (or drama or any of the other genres) It doesn’t work.

What do you mean ‘it doesn’t work’?

The conditional isn’t being applied? Or it won’t give you the option to change the background colour?

There’s not enough info to diagnose the issue.

What ‘type’ is the state? Maybe a few screenshots, or more detailed info would help.

Thanks. Sorry for the lack of clarity. I mean when I type action and press enter. it is red and doesn’t save/work/do anything. If I click out of the box, the word I typed disappears

It’s red… but is the value there? Or does the value not get entered?

Yes. the value ultimately is not entered.

do i have to put it ins quotes or apostrophes?

Here are some screenshots that show whats happening.

What ‘type’ is the custom state?

If it’s a text then you should just be able to type a value into the conditional, so the fact it’s not letting you suggests it’s not a text?

Yeah. the state type is Genre… which is part of the app data.

Here’s the screenshot of the genre data type:

Ok, so there’s your answer - you can’t give a ‘text’ value if the value needs to be a datatype (a Genre).

You need to refer to an actual specific ‘Genre’ (DB entry) - either by referencing a datasource on the page, (i.e. Group A’s Genre), or by doing a search for Genres and selecting a specific entry. (e.g. search for Genres, who’s name is Action, first item).

thank you so much! Don’t know what that didn’t occur to me! Actually I do. It’s because I’m a noob lol.

1 Like

One last question for another implementation. In a workflow, can I manually set a state to be a specific name in Genre? When I set state and then do a search for genre whose name is action, it doens’t seem to work.

I’m trying to do a simlar thing I have set up for the repeating group with buttons that come from a search for genres but with static buttons. Basically an “Action” button that is static and always sets the state of “genre button” to be Genre’s Name is Action

Yes, you can set the value of the state in a workflow, using the same method (search for Genres, who’s name is Action, first Item).

Although if your Button is inside a repeating group which (presumably) has a content type of Genre, then all you need to do is set the state to be the current cell’s genre.

Another thing that you might want to look into is using Option Sets for this instead of database entries.

It looks as though Option Sets are perfectly suited to what you’re trying to do (but without knowing more about your app I can’t say for sure).

But using option sets would simplify the process, and make it faster, as there’s no need to do any database searches. So it might be worth looking into.

You could also store the colour on the Genre (whether you use option sets or stick with database entries), then set the background colour dynamically to be the state’s Genre’s colour. That way you don’t need to use conditionals to set the background colour.

I can’t seem to get the commands you mention to come up when I’m setting this state. see screenshot. There was no “is” so I used “contains” and then there is no first item. See screenshot below:

Hey, @zoay,

In the search contraints you can have a contraint when the Name = whatever you want :slightly_smiling_face: :computer:

Thats what I tried initially, but it doesn’t allow me to input text there even though Genre name is a text field. see screenshot

That´s weird, try deleting the condition and do the same again.

If it doesn’t work, try having a filter in the search and inside the filter add the “Name = whatever”

Make sure you click in the actual input box, and not on the ‘click’ button (which will just open the dropdown of expressions). As long as your name field is a ‘text’ type you should be able to type it’s value.

Additional note: also be aware that searches are case sensitive - on some of your earlier posts you were typing ‘Action’ whereas on the last post you typed ‘action’.

These are different values, so you’ll need to make sure you use the one that matches your data entry.

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