Skip to main content
Nintex Community Menu Bar

Find index of an item in a collection

  • Apr 26, 2016 4:05 PM UTC
  • 11 replies
  • 98 views
  • Translate All

Forum|alt.badge.img+11

Hi,

Is there a way, without the use of a ForEach action, to query a collection variable by a value and get its index inside the collection?

I'm using Nintex Workflow 2013 on-premises

Giacomo

11 replies

Forum|alt.badge.img+17
  • Nintex Partner
  • Apr 26, 2016 5:14 PM UTC

No (Original Post)

Edit: From the help documentation, Exists returns a yes or no boolean that the value exists and not an index. But see Mike M​'s response, Exist does return an index.

Translate

Forum|alt.badge.img+17
  • Nintex Partner
  • Apr 26, 2016 5:23 PM UTC

HA, Sorry. I just wanted to post my shortest response ever. I can't find any way. There are no Collection operations that do this

Add

Remove

Count

Get

Exists

Sort

Pop

Join

Clear

Remove duplicates

Remove by value

And if you use Join, put into a string variable, there are no inline functions that can operate on the string to find an index

fn-Replace

fn-Remove

fn-Length

fn-Insert

fn-SubString

Translate

Forum|alt.badge.img+17
  • Nintex Partner
  • Apr 26, 2016 5:32 PM UTC

I didn't find anything using SharePoint calculated field formulas either

Calculated Field Formulas

Translate

Forum|alt.badge.img+17
  • Nintex Partner
  • Apr 26, 2016 5:33 PM UTC

So if this truly is the case, what are you trying to do with the collection?

Translate

Forum|alt.badge.img+7
  • Apr 26, 2016 6:08 PM UTC

laugh.png

Translate

Forum|alt.badge.img+12
  • Apr 26, 2016 7:54 PM UTC

That made me laugh grin.png

Translate

Forum|alt.badge.img+12
  • Apr 27, 2016 1:38 AM UTC

Hey all,

Actually you can do this with the Collection Operation action using Exists... but its not Andrews fault for not knowing because the Nintex documentation under the help menu is wrong.

.       You can use the "Exists" method of the Collection Operation to do exactly what you want.   Exists actually returns a numeric - the index of the 0 based collection.    You can log to history to see that this is true as I did below when I use Exists on the value Buffalo.  

Collection:

Index of Buffalo:

Cleveland;Columbus;Detroit;Buffalo;NYC;
3

Thanks,
Mike

Translate

Forum|alt.badge.img+17
  • Nintex Partner
  • Apr 27, 2016 3:02 AM UTC

Perfect Mike, thanks for checking it out for real! I should edit my response to not scare future readers away. (but it was so fun).

I'll get the help documentation updated to reflect this! Go Team!

Translate

Forum|alt.badge.img+11
  • Author
  • Nintex Partner
  • Apr 27, 2016 6:22 AM UTC

Hi Mike M​,

thank you very much for your clue!! and also thank you Andrew Glasser​ for all the reply you have posted here happy.png, especially the first one!

Thanks again, I was not so confident that there is a solution but, as always, this community is great!

Giacomo

Translate

Forum|alt.badge.img+7
  • Nintex Partner
  • Nov 9, 2018 1:20 AM UTC

Is there more information on this? If I try to save the results of an "Exists" test into anything other than a boolean variable I'm getting a coercion error. 

Translate

Forum|alt.badge.img+11
  • Author
  • Nintex Partner
  • Nov 9, 2018 8:21 AM UTC

Hi Jeff,

With a number (or integer, I don't remember exactly which one is ok) variable you should be fine

Translate