Confiforms display excerpt of textarea fields in tableview - or inline search on hidden fields

Jan
Contributor
May 29, 2019

We have a form with a textarea field and a tableview with inline search for this form. As the content of the textarea field has to be searchable, we included it in the tableview. The length of the text increases the line height so that we would like to 

- show only an excerpt in table view OR

- exclude this field from table view 

but still the field content should be searchable in the view. 

Is that even possible? 

1 answer

0 votes
Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 10, 2019

Yes, you can use trim/trunc or even truncWithExpand functions to limit the number of characters shown in the field

https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions

 

fieldname.truncWithExpand(100)

 Shows first 100 symbols from a field "fieldname"

Please be careful when you truncating the field's value which may have HTML as it may produce a broken output (truncating HTML contents so that it becomes not valid)

You might need to consider using "extractText" first

fieldname.extractText.truncWithExpand(100)
Andrei Neboian October 16, 2020

Hi Alex,

I have just tried the function 

fieldname.truncWithExpand(100)

 in the Confiforms Field macro. But I am getting the below result on my page in the Table View: 

st test test test st test test test test test st test test test test testst test test test test test <span id='sah7squ1lp' class='sah7squ1lp_c'><a href='#sah7squ1lp' onclick='cfExpandDetails("sah7squ1lp");return false;'>...</a></span><span class='sah7squ1lp_e' style='display:none'> st test test test st test test test test test st test test test test testst test test test test test </span> 

Apparently, the code is inserted correctly, but the page doesn't compile it.

What could I be doing wrong?

  • I am using Table view -> Confiforms Form Field -> in the Confiforms Field macro configuration, under "Field", I have entered myfield.truncWithExpand(100)

Thanks!

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 16, 2020

Well, the function "truncWithExpand(N)" is really not something to use with an HTML contents, as it truncates the characters... and can potentially cut your HTML contents in a very bad way

You should probably use "extractText" on this field first and then truncate.

fieldname.extractText.truncWithExpand(100)

  https://wiki.vertuna.com/display/CONFIFORMS/Virtual+functions

Also make sure, please that you are not on a ConfiForms version where we had a regression issue with escaping HTML contents (please always upgrade to latest version if possible)

Andrei Neboian October 16, 2020

I did try with "extractText" too. Unfortunately, I get the same result.

I started using ConfiForms about 2-3 weeks ago, so I guess the version must be pretty recent.

I also tried with ".renderAsHtml" at the end, but this didn't help either.

The field I am trying to truncate is a "Textarea."

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 16, 2020

Could you check the version of the app?

I have quickly verified the function and it seems to work for me...

http://recordit.co/DeUWAgo7Hg

Andrei Neboian October 16, 2020

The version is 1.2.36-AC

I have also noticed that your app looks slightly different than ours. For example, I don't have the highlighted text in the field description as in the image.

snip_20201016221229.png

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 17, 2020

OK, it looks like you are using Confluence cloud and therefore ConfiForms for Confluence cloud.

We have identified the issue and whitelisted this function to "not escape" the output generated (was preventing possible XSS vulnerabilities)

Andrei Neboian October 19, 2020

It works like a charm now. Thank you!

On a side note, is there a function in ConfiForms which allows the text to collapse again after it has been expanded (without refreshing the window)?

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 19, 2020

Not at the moment. This function works one way only. We have a feature request to get it extended, so it will be there one day

But I cannot give you any ETA at this point

Markisio
Contributor
April 12, 2023

hi @Alex Medved _ConfiForms_ 

I noticed the truncWithExpand doesn't work properly with WYISWYG Simple Editor. Any idea why?

thanks 

Alex Medved _ConfiForms_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
April 12, 2023

Well, it does work.. but you have to understand that it truncates the HTML that the WYSIWYG field stores

You need to either extract the text (using extractText function) and then truncate.. or not truncate the HTML contents with the mentioned function 

Alex

Like Markisio likes this
Markisio
Contributor
April 12, 2023

yh just figured out prior seeing this message :) .extractText().truncWithExpand

 

thanks 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events