Forum Discussion

JWT007's avatar
JWT007
Ideator II
6 years ago

Badly formed HTML in Aras FormattedText Fields

I have the following scenario.

I have a report action bound to an item type which performs a REST call to the Microsoft SSRS Report Server with a delimited set of IDs.

The RDL Report performs an SQL query against a fixed ItemType to retrieve the meta-data for the given IDs.

Problem #1: 

Several of the fields are of type FormattedText - although the relevant value may only be a few lines of text, Aras packs so much HTML and JavaScript around them that these Fields can exceed 100k characters.  If generating an XLS report, there is a hard limit on the length of any given cell (32767 characters) - if this limit is exceeded, the report blows up with a HTTP Response Code error.

Potential Solution #1.

I wrote a simple SQL Function to convert the formatted text field string to XML and back again to a NVARCHAR(max) which effectively strips all XML elements from the text...the *magic* happens in this statement.

  -- convert to XML and back to VARCHAR(max) again
  SET @result = CONVERT(XML, @result , 1).value('.', 'NVARCHAR(max)');

Problem #2:

In several data sets the FormattedText fields contain HTML string content which is not valid XML.   In this case, the conversion function blows up.

Examples:

  • undefined namespace prefixes:  '<o:p>...</o:p>'  (note: the prefix can vary)
  • invalid attribute definitions:  '<br \="" ... >

This means I have to identify and correct each special case with time-consuming REPLACE(Column, Find, Replace) calls - a few of those on 100k+ character strings starts to blow up the query times.  Only when the string is *clean* can I try to convert it to XML.  For example,

  SET @result = REPLACE(REPLACE(@result, '<o:p','<p'), '</o:p', '</p');
  SET @result = REPLACE(REPLACE(@result, '<u5:p','<p'), '</u5:p', '</p');
  SET @result = REPLACE(@result, '\=""', '');

I could go and fix each *special case* with one-time SQL scripts, but I cannot *guarantee* that Aras will not write new fields with invalid XML.

So my question is can Aras take a look at the formatted fields and *guarantee* that they will no longer write poorly-formed XML(HTML).  Maybe they could provide an out-of-the-box SQL functionality to make it possible properly prepare FormattedText fields for export.

NOTE: Maybe this has already been resolved - our current customer project is still using Aras 11 SP9. 
In that case, we just need to clean the old data and we are good to go.

6 Replies

  • Hi JWT007,

    Are you seeing this behavior on standard ItemTypes? If so, could you specify which one(s), so I can take a look at this in a more current version to see if this is still present?

    Chris

    • JWT007's avatar
      JWT007
      Ideator II

      Hi Christopher, thanks for the quick response.

      Unfortunately (if I am not mistaken) the only OOTB FormattedText property in the Aras InnovatorSolutions database is on the "Help" ItemType - which is empty by default.

      So while I am sure I could fudge some broken data :) I am not sure that would prove anything.

      In our customer project we have some item types that rely heavily on the FormattedText fields - but all in custom item-types.

      • christopher_gillis's avatar
        christopher_gillis
        Community Manager

        I see. I set up a custom ItemType with a formatted text property then and tested this in a local 12.0 SP4 instance. While I'm not seeing anything unexpected, I'm also testing it with relatively simple data.

        Are you able to elaborate on how the formatted text field is being used and what kind of data you're trying to retrieve? Are you trying to access a list of values stored inside of an HTML table for instance?

        Chris