CSV Import - How to overwrite existing data with empty fields?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gart
    Junior Member
    • Nov 2024
    • 4

    CSV Import - How to overwrite existing data with empty fields?

    Hello everyone,

    I'm facing an issue with CSV imports in EspoCRM. While creating new records works perfectly fine, I'm having trouble with updating existing records.
    My specific problem:
    • When I import a CSV file to update existing records
    • If a cell is empty in my CSV file
    • And the corresponding field in EspoCRM contains data
    • The existing data is not overwritten/cleared by the empty value

    Example:
    • An existing record has "Phone: 123456789"
    • In my CSV import file, the phone field is empty
    • After import, the phone number remains "123456789" instead of being cleared

    Is there a specific setting or method to force EspoCRM to overwrite existing data with empty values during CSV imports?

    Any help or guidance would be greatly appreciated.
    Thank you in advance!​
  • shalmaxb
    Senior Member
    • Mar 2015
    • 1592

    #2
    Maybe there will be a more elegant way, but here is my proposal:

    1. In your entity, to which you want to import, create a new text-field and call it phone2 (or alike). In my example the original field is named phoneNumber.
    2. Map your phone number from the CSV file to that field. This way you will have phone2 with number or without.
    3. Create a formula:

    Code:
    ifThenElse)
    phone2 == ' ',
    phoneNumber = null,
    phoneNumber = phone2
    );
    On executing this formula after having imported, it should copy the number from phone2 to phoneNumber. If phone2 is empty, it should set the phoneNumber to empty as well.

    After the import is done, you can delete the field phone2.
    Last edited by shalmaxb; 11-24-2024, 05:28 PM.

    Comment

    • Gart
      Junior Member
      • Nov 2024
      • 4

      #3
      Thank you for your response. I appreciate your help!

      However, I should clarify my needs: I need to manage empty fields for all fields in my CSV import, not just the phone field. Creating a specific formula for each field would be quite cumbersome as I have many fields to update. Moreover, we use the import system regularly (not just as a one-time operation), so we need a sustainable solution that can be easily maintained.

      Is there perhaps a global solution or setting that would allow empty CSV fields to overwrite existing data across all fields during import? This would greatly improve our regular data update process.

      Thanks again for your support!

      Comment

      • Gart
        Junior Member
        • Nov 2024
        • 4

        #4
        Hi,

        I'm bumping this thread as I didn't receive any feedback on my initial question.

        To reiterate, my key needs are:
        • A global solution for handling empty fields during CSV import
        • A method that works across all field types
        • A sustainable approach for our recurring data update process

        Would anyone from the community have insights or suggestions on how to systematically manage field updates when importing CSVs with empty values?

        Thank you in advance for any help.

        Comment

        • Gart
          Junior Member
          • Nov 2024
          • 4

          #5
          Hi community,

          Just checking if anyone has any ideas about my previous CSV import issue in EspoCRM.
          Is there a way to globally handle empty fields during import, ensuring existing data gets overwritten across all field types?
          Any suggestions would be much appreciated!

          Thanks,​

          Comment

          • yuri
            Member
            • Mar 2014
            • 8415

            #6
            Hi,

            It will be possible in the future version by setting CSV values empty.
            If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

            Comment

            Working...