Skip to main content
Nintex Community Menu Bar

Count items within a collection

  • July 28, 2017
  • 7 replies
  • 18 views

Forum|alt.badge.img+10

Hi community,

I have a problem with counting items within a collection (there are three items in that collection), and I am already getting mad about this. I tried three different approaches:

First try (Regular Expression):

206021_pastedImage_1.png

RESULT
colFachabteilungen: ["{""__metadata"":{""type"":""Collection(Edm.String)""}","""results"":[""Fachabteilung 1""

7 replies

Forum|alt.badge.img+16

can you not use collection operation - count?


Forum|alt.badge.img+16

Forum|alt.badge.img+10
  • Author
  • Nintex Partner
  • July 28, 2017

I used the "Count Items in Collection" object in my first and third try:

206027_pastedImage_2.png

I don't know why it does not work. sad.png


Forum|alt.badge.img+13
  • Novice
  • July 28, 2017

If you query the list and be sure to Store Output in separate collection then the COUNT collection will work.


Forum|alt.badge.img+10
  • Author
  • Nintex Partner
  • July 28, 2017

Hi Ryan,

Isn't that what I have done in my "second try"? Ok, I didn't use an extra/separate Count Object here, because the Query List object has a result count for itself. Nevertheless I added the Count Object and received the same number as with the included result count within the Query List object: 1 (see also initial posting "second try").

Cheers

mai-kel


Forum|alt.badge.img+13
  • Novice
  • July 28, 2017

Sorry, didn't see that you had used that setting.

Your output doesn't look correct.

[["Fachabteilung 1","Fachabteilung 2","Fachabteilung 3"]]

This is an array inside your collection.

Your collection should look like

["Fachabteilung 1","Fachabteilung 2","Fachabteilung 3"]

I think I've figured out the issue whilst typing this in fact. I'm guessing that Fachabteilungen is a multi select choice column or similar.

This would explain why your query list doesn't work as you're only looking to return a single result that contains 3 values. Not 3 results.

There might be a more elegant way of doing but you could add a regex in to remove the leading [ and trailing ]. This will leave your collection in the correct format to perform operations on.


Forum|alt.badge.img+10
  • Author
  • Nintex Partner
  • July 28, 2017

Hi Ryan,

You are right - it is a multi select choice column.

And with the help of my colleague Jan von Reith‌ I found a solution (I guess the same solution you were refering to):

1. Query list object:

         column into COLL variable

2. Regular expression object:

         String: COLL variable

         String operation: Split

         Pattern: ,

         Output: COLL variable

3. Count Items in COLL object

Cheers

mai-kel