Change a custom status within a repeating group

I have a repeating group of items which users can select and deselect by clicking on each item.

There’s a separate button to change the selection of items shown.

In the frontend workflow, I go to Element Actions > set state. All my elements appear other than the repeating group element, so I can’t change the set state from “selected” to “unselected”.

Any ideas of how to do this if repeating groups can’t be edited from outside of the repeating group?

Hi there, @angus.hally… if I understand your post correctly, you could have a custom state at the page level (that’s where I put most of my custom states so they are easy to find) that stores a list of things that have the same type as the items that are being displayed in the repeating group. Then, when an item is selected, set the custom state to its current value plus the item that was selected. When an item is unselected, set the custom state to its current value minus the item that was unselected.

Does that make sense and sound like it could work for you?

Best…
Mike

1 Like

Hi Mike,

Thanks for your response. It does make sense but doesn’t solve my issue, let me explain in more detail. When I click on a item, I want it to be selected, and deselected if I click it a second time. This is how i’m currently achieving that:

When item is clicked (I should state, there’s no “select” or “deselect” option, the item is just clicked once to select and clicked again to deselect.

  • item click count += 1
  • item is added to list of selected items at page level if item click count MOD 2 = 1
  • Item is removed from list of selected items at page level if item click count mod 2 = 0

This all works fine. But since the item click count is specific to the item the custom state has to be within the repeating group.

The problem happens at the next part. I want to use a second button (change date) to show different items, and remove any selections i’ve previously made. However, if I click item 1 in repeating group, then change the date, the new item 1 takes on the click count of the original item 1. Hence this messes with my logic for adding and removing items from page state. I’ve tried to find a way to reset the click count to 0 or to stop the custom state passing from one item to another, but doesn’t seem possible.

Does that make more sense?

Honestly, no. Well, not to me, at least.

It still seems to me that the custom state I described could do the trick here, but it sounds like you are pretty sure it won’t work, so I will let others who better understand your post jump in on this one.

1 Like

no worries, thanks anyway :slight_smile:

I think this answers my question: repeating groups cannot be accessed by external elements. Cant find repeating groups to set the state - #4 by williamtisdale

Will need to find another way

Hey I think @mikeloc solution would still work for this use case. Just when the change date button is clicked then set the state of the custom state “selectedItems” to only the current cell’s item. That way it will clear all other selected items and starts you off fresh with the next item. Also then you don’t have to have more than one custom state. Just one which would be selectedItems. Then the conditional on each cell could just be if custom state selectItems contains current cell’s items (style as a selected item).

2 Likes

Ah thanks that works.

I was making it more difficult than necessary by using conditionals at workflow step level rather than at the workflow level.

Thanks both.

2 Likes