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
Molson94Molson94 

Creating CSV from List: Handling Null Values

Hello,

I am creating a CSV file to email and attach to the parent object.
What I am running into is that any fields without values are being added to the csv file in the email as "null".

This makes sense since not all fields will have values.
Is there a way around this? Ideally the csv file would show blank instead of null.

Thanks!
Best Answer chosen by Molson94
Shashikant SharmaShashikant Sharma
Hi,

Instead of using direct field value like objInstacne.Field__c put a null check condition.

( objInstacne.Field__c != null ) ? objInstacne.Field__c : ''; 

Here objInstacne is the instance of the record and Field__c is the API name of the field.

Let me know if you still face issue.

Thanks
Shashiakant

All Answers

Shashikant SharmaShashikant Sharma
Hi,

Instead of using direct field value like objInstacne.Field__c put a null check condition.

( objInstacne.Field__c != null ) ? objInstacne.Field__c : ''; 

Here objInstacne is the instance of the record and Field__c is the API name of the field.

Let me know if you still face issue.

Thanks
Shashiakant
This was selected as the best answer
Molson94Molson94
Hi Shashiakant,

I tried what you mentioned above but i am still getting compiling errors.
Depending on the field that i am using i am getting some variation of: Incompatible types in ternary operator: Decimal, String