function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
CJMCCMDCJMCCMD 

HTMLENCODE(row[column]) doesn't work.. Any suggestions?

I have code to output rows and columns from a controller's data member (a SObject[] collection).

 

The code below works fine. It iterates throough each row in rpt.data, and through each column name in rpt.parsed_clean_field_names, and using a bracket notation, outputs the row[column] just fine.

 

<apex:repeat value="{!rpt.data}" var="row">

     <apex:repeat value="{!rpt.parsed_clean_field_names}" var="header">

              <apex:outputText value="{!row[header]}" escape="false"/>

     </apex:repeat>

</apex:repeat>

 

But when I try to use HTMLENCODE to encode the data (since it may contain characters that I want encoded), I do this (the red bold is the only difference): and it breaks

 

<apex:repeat value="{!rpt.data}" var="row">

     <apex:repeat value="{!rpt.parsed_clean_field_names}" var="header">

              <apex:outputText value="{!HTMLENCODE(row[header])}" escape="false"/>

     </apex:repeat>

</apex:repeat>

 

with the following error message:

Incorrect parameter type for function 'HTMLENCODE()'. Expected Text, received Boolean

Error is in expression '{!HTMLENCODE(row[header])}' in component <apex:outputText> in page exportreport3
 
Apparently HTMLENCODE doesn't recognize the row[column] "getter" notation.
 
Any suggestions as to how I could fool HTMLENCODE into thinking that row[column] is a Text and not a Boolean??
 
Thank you
 
Chris
 
 
Avidev9Avidev9

Well not sure.

But can you try something like this

 

 <apex:outputText value="{!HTMLENCODE(TEXT(row[header]))}" escape="false"/>

CJMCCMDCJMCCMD

Good idea..  But it caused Salesforce itself to fail, and not even return a valid HTML page, with the following error.  I've never seen this before.  Any thoughts?

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!


Error ID: 206456986-7913 (256181728)


Avidev9Avidev9
Well I guess this is something only SF support will be able to help.
I guess best way will be is to raise a ticket
NIkhil Dandekar 18NIkhil Dandekar 18
I have also a same requirement where i need to render the HTMLENCODE for <apex:outputtext> without knowing the dataType it should work for all the fields types. As they are dynamic fields. Some are date, boolean, text types
It is also iterating over <apex:repeat></apex:repeat> over dymnic fields in object query.
Getting below error.
Incorrect parameter type for function 'HTMLENCODE()'. Expected Text, received Boolean