Solved

How to get the length of a string?

  • 31 August 2016
  • 9 replies
  • 416 views

Badge +4

I have a workflow where I want to get the length of a string (Eg: TE00000284) to use it in further cases.

I tried using fn_Length(TE00000284) in 'Convert Value' Action and tried to store the length in number variable and

TE00000284 has been passed in single line text variable.

 

But, unfortunately it's throwing an error stating

"Error parsing value. Value 'fn_Length(TE00000284)' is not compatible with the selected output variable type Number (double)."

 

Please help me with the error...

icon

Best answer by divyam 2 September 2016, 12:36

View original

9 replies

Badge +8

Hi Divya,

I tried this myself and could not find the error. Are you using a hardcoded string to check the length (TE00000284) or are you checking the length of the string that is stored in a textbox? Can you try using a string variable to store the count?

Regards,

Shrini

Badge +4

Hi Shrini,

Thankyou.

I'm taking the string value from list column. Anyways I tried both cases as well (mentioned above) but getting the same error.

Badge +8

Hi Divya,

I have tried this quite some time before as well and it does give the correct result. Could you please copy paste your actions (images) to show what exactly you are doing?

Regards,

Shrini

Badge +11

Try setting the variable that gets the length to an integer.

Badge +4

This is the workflow I'm using and dont know where I went wrong..

I took two variables as below

I have taken the string value from current item and assigned it to Sting variable.

In Convert Value I used the function fn_Length(String) to get length of string passed and stored the value in Number variable. And tried to log the value.

But I'm getting the same error as mentioned above... Please help me in resolving this issue.

Badge +8

Hi Divya,

It seems a bit odd, I tried very quickly creating the same workflow you showed above (just to be sure if i am not seeing anything) and there was nothing wrong in it. The only thing I can think of what is the data type of the "Sequence Number" field? Could you try the following (this may not solve your issue but can help you troubleshoot your issue further)

1] Get details from soem other field other than sequence number shown above, see if it works ..

2] Use trim with the length function so that spaces dont get counted.

Further it looks very straightforward and not sure what exactly could be wrong other than the field sequence number as thats the only unknown in this scenario. Try this and let me know if it works.

Regards,

Shrini

Badge +4

Thankyou everyone.

It is working fine now. I really found my mistake where I used fn_Length(String) instead of fn-Length(String) Hence it was throwing an error.

Now it is working fine ...

Thankyou again

hola , 
esta tambien es una manera en la que pude optener el tamaño de una cadena que tienen numeros sin que me presentara error, poniendo antes de la variable o el control ""  y concatenarlo con un +


























length(""+IDNo)












Badge +1

Hi,

Just for information.
I ran into a similar issue but was caused from something completely different.
Adding quotes might help in some cases but it adds the Length number as well. So using quotes and pluses is increasing the result.

Nevertheless I got a parsing error as well but in my case I was calculating the length of a multiline text field. This is Rich text so included HTML.
I first Regex by (<([^>]+)>) to remove the coding. Then build a string using fn-Length(fn-XmlDecode({WorkflowVariable:Initiative Title}))

The parsing error occurred because apparently the user used brackets in the text but forgot to use both (only ( instead of () ). This causes a broken formula on the Nintex workflow because it looks like that Nintex is processing the formula as plain text and not a safe string.
Then you get something like fn-Length(some text using ( and again () but no closing bracket so missing one.) --> fn-Length((())



I made sure to replace brackets by "" (nothing) before parsing length.

Reply