3

I have a client who has asked me to run an automation based on some report data which includes long text fields. I was playing around with sample code:

String reportId = 'insert a tabular report ID here';

// Run a report synchronously
Reports.reportResults results = Reports.ReportManager.runReport(reportId, true);

// Get the fact map from the report results
Reports.ReportFactWithDetails factDetails =
    (Reports.ReportFactWithDetails)results.getFactMap().get('T!T');

// Get the field value from the first data cell of the first row of the report
Reports.ReportDetailRow detailRow = factDetails.getRows()[0];
for (Reports.ReportDataCell rdc : detailRow.getDataCells()){
    System.debug(((String)rdc.getValue()).length());
}

So what this does is tell me the string length of each cell of the report's first row. That first row contains over 6000 characters, but I get a length of only 1002. When I dump the actual value I can see it's been truncated with "..." at the end. In the Classic UI when I view this report I see the full length of the text field.

I can't seem to find any references to this... why is Apex only finding a truncated value? Is there anything I can do from the Reports namespace (rather than query the original records) to find that data?

  • Reporting API queries data from a report, so I am assuming, report API will respect the limits of a standard report. This could be related to the long text limits on report described here: help.salesforce.com/… – Rao May 1 '17 at 17:39
  • Well the part about "Only the first 254 characters in a rich text area or a long text area are displayed in a report." - not getting that as I'm getting 1000 characters. Just very strange that Apex itself has this constraint too. – Charles T May 1 '17 at 17:49
  • If you do a search for long text the docs also say "When you filter on standard long text area fields, such as Description or Solution Details, only the first 1000 characters of the field are searched for matches in reports." probably because it searches for the first 1000 chars it displays the 1000 when you do report details in report API is my guess. Also I see that the first 999 characters are extracted and with the silly ... it adds up to 1002 characters – Rao May 1 '17 at 17:53
  • Only the first 1000 characters are searched for matches. I'm trying to actually fetch the value of the field not filter on it. – Charles T May 1 '17 at 18:14
  • I have not played too much around long text fields and limitations, so I am as clueless as you are on how to fetch more than 1000, unless you are open to query a specific object and fetch the data I don't see a way using reportingapi – Rao May 1 '17 at 18:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.