How to Generate a File with an Empty Line (with Spaces Only) from an Empty NetSuite Saved Search

In some integration scenarios, business requirements demand that a file is always sent—even when your NetSuite Saved Search returns no records. However, instead of sending a completely blank file, you may be required to send a file that contains one line (e.g., a line with just spaces). In this tutorial, we’ll walk through how to achieve this using Celigo’s integration flow.

Below are the key steps to ensure your integration flow triggers correctly and generates a file with an empty line (with spaces only) when no records exist in the Saved Search.

Step 1: Ensure the Flow Triggers for an Empty Saved Search

By default, if a Saved Search returns no records, the integration flow might not trigger. To force the flow to execute, you need to modify your NetSuite export configuration by adding a preSave hook. In this hook, you can push an empty object into the data array if it’s empty. This ensures that the flow continues through the subsequent steps.

Example preSave Hook Code:

Explanation:

  • Check for No Records: The hook first checks if the data array is empty.
  • Push an Empty Object: If it is, the code pushes an empty object ({}) into the array, ensuring that there is at least one record.
  • Return the Data: The modified data array is then returned, allowing the flow to continue.

Step 2: Configure the FTP Step for CSV Generation

Next, configure the FTP step that generates your file. Here are the settings you need to set up:

  1. File Format: Set the file format to CSV.
  2. Delimiter Settings:
    • Column Delimiter: Choose a comma (,) as the delimiter.
    • Row Delimiter: Set it to a newline character (\n).
  3. Truncate Last Row Delimiter: Make sure to check the box for "Truncate last row delimiter."
    This option ensures that there is no extra empty row at the end of your file, maintaining the correct format.

Step 3: Map the FTP Step to Output a Hardcoded Space

Now, ensure that the file outputs a line with spaces only when no actual data records are present:

  1. Mapping: In the FTP step’s mapping configuration, choose any destination field key.
  2. Hardcode a Space: Map the chosen field to a hardcoded space character (e.g., " ").

This mapping guarantees that when the empty object is processed, the output file will contain a line with a space instead of being completely blank.

Final Thoughts

By following these three steps, you can ensure that even when your NetSuite Saved Search returns no records, your integration flow will generate a CSV file with a single line containing spaces only. This approach meets the requirement of sending an empty file with a placeholder line, thereby satisfying the requirements of companies that expect a file format consistency even when no data is present.

1 Like