Truncating the text of a Record inside a Report


Peter Bradstreet
Hi,

In my Report I am showing a list of notes including the title and body of the note below in each row. I would like to truncate the body of the note in the grid view if the note is longer than xxx characters. For example, if I set xxx to 16 then "This is a longer sentence that has more than 16 characters" would be truncated to "This is a longer..." but "This is short" would remain as "This is short".

I figured that the easiest solution would be to store the truncated body in a separate field such as note_truncated when adding or editing a record(note) and show 'note_truncated' in the report but show the full 'note' in the edit view.

I was wondering whether you have done anything like this before in AB using existing string functions or would I need to create a custom function?

Thanks, Pete

DecSoft

Hello Peter,

Talking about some string inside a Report, I am not sure if we can use a bit of CSS to do what we wanted, probably yes, but, also it's possible to use a code like the below one, inside the Report's HTML:

Above you can see two "span" elements. If the "Record.Name" is less or equal to 4, then the Record.Name is printed out as is, in other words, the first "span" appear visible, and not the other one. On the other hand, if "Record.Name" is greater than 4, then the "Record.Name" is truncated using the "substr" Javascript function, so in this last case the second "span" is show, and not first one.



Peter Bradstreet
That is really cool. Thanks very much!

DecSoft

No problem! :-)


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.