29 views

Description

List Reports show raw HTML tags such as <p>. In the list view the tags are hidden from the HTML field content.

Steps to Reproduce

 

  1. Log in and navigate to Reports > View/Run.
  2. Click on the button 'All'.
  3. On the Report's search box search for "knowledge".
  4. Click on 'Knowledge created by Author'.
  5. Change the report type from Trend to List.
  6. In the Configure tab, click on Choose columns
    • Add the Text field to the report by moving it from the Available to the Selected slushbucket.
  7. Click on the button 'Run'.
  8. Click on the arrow to the right side of 'Author: Boris Catino'.
  9. Note that the Text column contains HTML tags.
  10. Open 'Author: Boris Catino' on a new tab (right-click on it and select Open on a new tab).
  11. Note that the Text column does not show HTML tags.

Workaround

This is working as designed in all current versions. The workaround/enhancement described below requires the creation of a new string field on the target table, which in this example is kb_knowledge.

The background script in step 2 is used to strip the markup from the HTML field value and save it into the new string field. It does this for all existing records.

The before insert/update business rule in step 3 is to apply the same process to new and updated records. Now the plain text field can be used for reporting and lists.

  1. Create a string field on kb_knowledge with max length 65000
  2. Run the following background script, after adjusting the table and field names:
    var kb = new GlideRecord ( 'kb_knowledge' );
    kb.query();
    
    while ( kb.next() ) {
      var html = kb.text; //HTML field
      html = html.getHTMLValue();
      var doc = GlideXMLUtil.parseHTML(html);
      var b = doc.getDocumentElement().getTextContent().trim();
      kb.u_plain_text = b; //u_plain_text is the new string field
      kb.update();
    }
  3. Create a before insert/update business rule on kb_knowledge with the following script:
    (function executeRule(current, previous /*null when async*/) {
      var html = current.text; //HTML field
      html = html.getHTMLValue();
      var doc = GlideXMLUtil.parseHTML(html);
      var b = doc.getDocumentElement().getTextContent().trim();
      current.u_plain_text = b; })(current, previous); 

 


Related Problem: PRB1066380

Seen In

There is no data to report.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-09-18 01:01:18
Published:2018-09-18