Count the number of lines used in a longtext field

Is there an expression to use for counting the number of lines used in a Longtext field ?

Option 1 (preferred)
Count the number of lines used in a Longtext field (and limit if needed).

Option 2
I can use field type = Text, but the view when typing in the field on the form is single line and the user can only see several words previously typed instead of the desired previous sentence(s) while typing.

I am trying to find a quick and easy way to identify how many pages the resulting PDF will be and this is the only field that can grow.
If there is a solution to one or both of the options then I should be able to ultimately have a Page x of x on the resulting PDF.

Thanks,
Bill

0 12 456
12 REPLIES 12

Maybe try:

LENGTH( SPLIT( [column] , "
" ) )

@Marc_Dillon
Coult it be the COUNT() expression instead of LENGTH()? (LEN() )

I guess weโ€™ll never know.

Yes. The Count function instead of Len function works correctly.

Now my dilemma is that I need to identify or limit the Longtext field to a combination of 1,591 characters and 15 lines.
Exceeding 15 lines in this field on the PDF will cause there to be two pages instead of one.
Exceeding 1,591 characters (if single line) in this field on the PDF will cause there to be two pages instead of one.

I am trying to find a solution that will work for Single line and multiple line simultaneously.

I have tested that below expression works very well:

COUNT(SPLIT(
SUBSTITUTE([LONG_TEXT],"
",","),","))

Thank you LeventK,
Now my dilemma is that I need to identify or limit the Longtext field to a combination of 1,591 characters and 15 lines.
Exceeding 15 lines in this field on the PDF will cause there to be two pages instead of one.
Exceeding 1,591 characters (if single line) in this field on the PDF will cause there to be two pages instead of one.

I am trying to find a solution that will work for Single line and multiple line simultaneously.

You can use below Valid_If expression for your long text column

AND(
COUNT(SPLIT(
SUBSTITUTE([LONG_TEXT],"
",","),","))
) <= 15,
LEN([LONG_TEXT]) <= 1591
)

Did it not work without the substitute()? If so, I would substitute a different character for the newlines, like a semi-colon or something else uncommon, in case the user wants to add commas in as part of his text.

I have tested it and it works. However, you have a right. Instead of a comma (,) it will be better to use another delimiter. Also I forgot to mention @Bill_Hyde that he needs to check the string length for (1591 + 14) chars instead of 1591, as each newline will be counted as 1 character.

Here is the final result:

AND(
COUNT(SPLIT(
SUBSTITUTE([LONG_TEXT],"
","|"),"|"))
) <= 15,
LEN([LONG_TEXT]) <= 1605
)

What would be the expression for โ€œCHAR Countโ€ by itself ?

the second argument to the AND()

LEN( [LONG_TEXT] )

This gets me closer to my destination.
Thanks to you and LeventK.

Top Labels in this Space