You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi. I am trying to create my implementation of SOQL to CSV and currently struggling with some issues like mixed field order or handling of parent and child relations.
Could you try to implement in your lib output conversion to CSV? Such a method should have a separator parameter as it is a comma or semicolon in different countries.
In my case business requirement is to make a report from surveys where we use text fields with 10000 characters in length. Bussines found that in such case field in report is truncated to 255 characters. According to SF documentation, this is expected behavior https://help.salesforce.com/s/articleView?id=000389623&type=1 . They want to have a report with full text field values.
My current implementation is below so you can understand what I am talking about.
publicstaticStringqueryToCSV (List<sObject> records, Stringdelimiter) {
StringnewLine='\r\n';
List<String> allCSVRows=newList<String>();
Set<String> fieldNames=newSet<String>();
List<Map<String, Object>> listOfRecords=newList<Map<String, Object>>(); // List of single records represented by Map<FieldAPIName, FieldValue>// Extract data from records listfor (sObjectrecord:records) {
Map<String, Object> oneRecordFieldValuesMap=record.getPopulatedFieldsAsMap();
listOfRecords.add(oneRecordFieldValuesMap);
fieldNames.addAll(oneRecordFieldValuesMap.keySet());
}
List<String> tempRow=newList<String>();
// Build CSV headerfor (StringfieldName:fieldNames) {
tempRow.add(fieldName.escapeCSV());
}
allCSVRows.add(String.join(tempRow, delimiter));
// Add data rowsfor (Map<String, Object>valuesFromRecord:listOfRecords) {
tempRow.clear();
for (StringfieldName:fieldNames) {
Objectvalue=valuesFromRecord.get(fieldName);
if (value==null) {
value='';
}
tempRow.add((''+value).escapeCSV());
}
allCSVRows.add(String.join(tempRow, delimiter));
}
// Stick all rows togetherStringfinalCsv=String.join(allCSVRows, newLine);
allCSVRows.clear(); // free heapreturnfinalCsv;
}
The text was updated successfully, but these errors were encountered:
Hi. I am trying to create my implementation of SOQL to CSV and currently struggling with some issues like mixed field order or handling of parent and child relations.
Could you try to implement in your lib output conversion to CSV? Such a method should have a separator parameter as it is a comma or semicolon in different countries.
In my case business requirement is to make a report from surveys where we use text fields with 10000 characters in length. Bussines found that in such case field in report is truncated to 255 characters. According to SF documentation, this is expected behavior https://help.salesforce.com/s/articleView?id=000389623&type=1 . They want to have a report with full text field values.
My current implementation is below so you can understand what I am talking about.
The text was updated successfully, but these errors were encountered: