Skip to main content
Nintex Community Menu Bar
Solved

Get length of a string in NWC Workflow

  • Oct 20, 2022 6:38 PM UTC
  • 8 replies
  • 546 views
  • Translate All

Forum|alt.badge.img+5

Hello,

 

How can I get the length of a string in NWC Workflow. I see there is a Length function in NWC Forms, but I am looking for this in NWC Workflows. 

 

Thank you.

Best answer by Simon Muntz

Hi,

 

My approach would be to use a Regular expression to split the string up into a collection.
The config would look like this:

Then use a Count Items in collection action to count how many letters there are in the collection.

For some reason the count is always one more than required so just use a calculate a value action to subtract one.
 

Workflow would look like:

Export Key valid until this time on the 24th of October:
ma8vjTraMZYyHn6CzTfFM3tZmXRbDYTKWG5sGGUwxgjkkxap2

View original

8 replies

Forum|alt.badge.img+11
  • Contributor
  • Oct 20, 2022 10:07 PM UTC

May or may not work depending on the string your starting with.

 

 

Translate

Forum|alt.badge.img+5
  • Author
  • Scholar
  • Oct 20, 2022 10:28 PM UTC

Thank you @bsikes !!

 

That is rather counter intuitive, but it worked! 

Translate

Simon Muntz
Nintex Partner
Forum|alt.badge.img+23
  • Nintex Partner
  • Answer
  • Oct 20, 2022 10:57 PM UTC

Hi,

 

My approach would be to use a Regular expression to split the string up into a collection.
The config would look like this:

Then use a Count Items in collection action to count how many letters there are in the collection.

For some reason the count is always one more than required so just use a calculate a value action to subtract one.
 

Workflow would look like:

Export Key valid until this time on the 24th of October:
ma8vjTraMZYyHn6CzTfFM3tZmXRbDYTKWG5sGGUwxgjkkxap2

Translate

Forum|alt.badge.img+5
  • Author
  • Scholar
  • Oct 21, 2022 10:00 PM UTC

Thank you for this alternative solution, @SimonMuntz .

 

I tested your example and it works great for a single word. The string we want to check the length of could be any number of words, spaces and punctuation. What regex would you recommend for that situation? 

Translate

Simon Muntz
Nintex Partner
Forum|alt.badge.img+23
  • Nintex Partner
  • Oct 23, 2022 9:20 PM UTC
Hi,

I think this regex would cover it.
[Ss]
Translate

Forum|alt.badge.img+5
  • Author
  • Scholar
  • Oct 31, 2022 11:13 PM UTC

Thank you @SimonMuntz 

 

The regex [Ss] did indeed work with multiple words. And it even worked when I included a trailing space. 

 

I think this solution is cleaner than one I previously marked as the answer.

Translate

Forum|alt.badge.img+11
  • Contributor
  • Nov 1, 2022 1:22 PM UTC

My only concern with @SimonMuntz suggestion, and this may be unfounded, was if there was a max limit on a collections size. I have no idea if there is one - but if there is, that may be a limitation you run into with that solution. 

Translate

Simon Muntz
Nintex Partner
Forum|alt.badge.img+23
  • Nintex Partner
  • Nov 1, 2022 10:02 PM UTC

Hi,

 

Collection do have a limit of 5000 objects.

So as long as the string is under 5k characters (which is a lot) my solution will work.

Translate