Combination View Flat View Tree View
Threads [ Previous | Next ]
Hello eveyone,

I'm trying to compare the length of an element data to a constant number. For example if the number entered in the element data is equal to seven digits then it's a valid number or else the number is not valid.
Can this be done without using java coding?

Thanks for your assistance,

Fabien

duuplicate question

No. There's nothing within studio that gives you the number of digits in a variable (string length.).

Hi Janine,

There is no built-in way to get the length of a string without programming unfortunately. Decision editor allows you to do String comparison, but not get the length of the string.

Here is an idea that should work in your situation, though, which involves a number. You can make a decision editor decision check if the number is greater than 999999 and if it is, the number has 7 digits. You can write a cascading decision such that you have different exit states based on the number of digits in the value. For example:

if num > 999999 then return 7-digit
else if num > 99999 then return 6-digit
else if num > 9999 then return 5-digit
else if num > 999 then return 4-digit
else if num > 99 then return 3-digit
else if num > 9 then return 2-digit
else return 1-digit

Hope this helps!