@Length and Rich Text fields

I’ve got a form with a Rich Text field on it, and a Text field. I have added a graphic next to each field that should display if the contents exceeds 4000 characters. The onChange event of the RTF field calls uidoc.Refresh to make sure that the script can see the contents of the RTF field.

Can someone explain why the formula for the rich text field below has to be different to the normal text field, for it to behave in the same way? I have to check on 4002 characters for RTF fields and 4000 for normal text fields.:

Hide formula for graphic next to RTF:

@Length(@ReplaceSubstring(@Text(field1); @NewLine; “…”))<=4002

Hide formula for graphic next to text field:

@Length(@ReplaceSubstring(@Text(field2); @NewLine; “…”))<=4000

The same text pasted in to each field of 4001 characters makes the graphic appear next to them, 4000 or less and the graphic goes away. But if I change 4002 to 4000, I see the graphic when there is 3999 characters.

It would be nice to have an exact explanation as to why this is happening so I can rule out the possibility of some bizarre combination of characters in the RTF field breaking the system and getting the graphic to display when it shouldn’t. Is it just as simple as saying there is an internal 2 characters added to all RTF fields by Notes? Or does Notes stick a carriage return on the end of the field?

Any help would be brilliant. Thanks,

Andy

Subject: @Length and Rich Text fields

I don’t know the answer, but it seems like you could make a text field with the formula

@ReplaceSubstring(@Text(field1); @NewLine; “…”)

and find out what is in there. Rich text doesn’t magically add any characters to the text of the rich text, but you might well be getting a terminating newline that adds ‘…’. It should be fairly easy to see in a text field.

Subject: RE: @Length and Rich Text fields

Thanks for the idea, it seems that rich text fields start with a newline before any value you add to them, which would explain the extra 2 characters for a line break and a carriage return.