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.