Forum Documentation Showcase Pricing Learn more

Any way to know the numeric position of a specific entry within a list

#1

I’m trying to find the position of a text entry within custom state that’s set to be a list of text fields. Additionally, I’m running a workflow on this list so I want the position of each entry as I submit it to an API workflow on the list – so something hacky that works for 1 entry isn’t viable here.

Any ideas for how I might approach this?

#2

On top of my heard no native bubble solution comes to mind but you can easily do this in javascript using the Array indexOf() function.

For example if you have a list as names = ['John','Mary','Peter', 'Dave','Anne'],
then calling names.indexOf('Dave') will return 2.
Note that javascripts arrays count from 0 so first position is 0, second is 1 and so on.
If the item is not in the list, it will return -1.
If the item appears more than one in the list, the first position found will be returned (since bubble lists don’t have duplicates this shouldn’t be an issue for you).

So you can easily use the toolbox plugin and the JavascriptToBubble element to get the value from javascript into bubble.

2 Likes