Length() from Numeric Field

  • 11 November 2017
  • 9 replies
  • 105 views

Badge +3

Hello All:

I have a purchase requisition field within a Nintex Form and I need to set a rule that would allow either 8 or 9 digit length numbers.  I thought I would just set a form variable to make this determination at runtime using:

length(MyPurchaseRequisitionField)

However, after testing this using a calculated fielded on the form, I noticed it would return "#value!‌ " if I entered into this field "123" or any fully numeric string.  If, on the other hand, I entered "123a" then I would get a correct length of 4.

Obviously length() seems only capable of working with either an alpha or alpha-numeric string and not a fully numeric string.

Originally I had planned on using this variable within a validation rule and the "||" or logic to enable this but without being able to determine the length of a fully numeric string I am stuck.

Does anyone know a way around this or perhaps has another idea of how to accomplish this type of validation?


9 replies

Badge +16

Try this instead:

length(subString(Name,0,length(Name)))

123 equates to 3 for me

Badge +9

Why not using range validation?

210573_pastedImage_2.png

Badge +3

Worked perfectly!  Thanks!

Badge +16

OK just be careful I looked at another post earlier, similar issue, where substring ignores any leading zeros.  it happens on above solution too.  so if you are likely to have leading zeros you will need something else (though I can't work out what yet)!

Badge +3

Thanks for the heads-up; however, I'm good as I've no leading zeros to contend with. 

Badge +3

Thanks for the advise, I appreciate it.

Userlevel 2
Badge +5

This seemed to work until I got to 23 numbers. For example, the string "012345678901234567890123" returns 22 as the length. Numbers beyond that continued to report 22. If I add a character to it, it returns the correct value. If I remove the character, it goes back to 22.

Badge

I am so glad you pointed this out, as I came across this for a project I'm working on and do have leading 0's. Thank you!

 

For my use case, I only care about how many characters are in the number that I am storing in a text control, not what the numbers are, so I was able to use the replace function to change the 0's to 1's, then use the length function on that. So I ended up with with this formula in my calculated value control:

 

length(replace(Name,"0","1"))

 

I was then able to create a rule to hide my panel so that they can't fill out the rest of the form until they put the right amount of characters in the control. I was using a regular expression as another comment suggests, but I wanted to catch them sooner than when they submit for this particular form.

Badge

Old post, new ideas. I just came to this issue when fixing an old form (Nintex for SharePoint 2010).

This worked for me:

length(toLower({Self}))>10

Aparently when addind toLower function, it implicitly converts to string. Then, bingo!

Reply