Create Records

Definition

The Create Records action allows you to add multiple new rows of data to a specified zenphi Table in a single operation. This action is designed for bulk data entry, enabling you to efficiently populate a table with a collection of records from a previous step in your flow, such as from a Google Sheet, a database query, or an API call.

  • Key capabilities:
    • Select any existing zenphi Table as the destination for the new records.
    • Add a batch of records from a list or array of data.
    • Map data from your source collection to specific columns in the target table.

This action is fundamental for automating data synchronization and bulk-loading tasks, eliminating the need to add records one by one.


Inputs

  1. Table

    • Purpose: This field is for specifying the exact zenphi Table where you want to create the new records. It acts as the destination for your data.
    • Practical Guidance: You will typically select the table from a dropdown list that shows all available tables in your zenphi environment. This is a static selection, meaning you choose the specific table you want to populate when you build the flow.
    • Use Case Context: You would use the 'Table' field to tell the action, for example, to add new entries to your "Customer Orders" or "Project Tasks" table.
  2. Collection

    • Purpose: This field is for providing the data that you want to add to the table. It expects a list or an array of items, where each item in the list represents a new row to be created.
    • Practical Guidance: This value is almost always provided dynamically using the token picker. For example, you might use the output from a "Read Rows" action from Google Sheets or a "Query Records" action from another table. The entire list of rows from that previous action would be passed into this field.
    • Use Case Context: You would use the 'Collection' field to supply the list of new employee details that you want to add to the "New Hires" table.
  3. Select fields to create records

    • Purpose: This section is for mapping the data from your input Collection to the corresponding columns in your destination Table. This tells zenphi which piece of data from your source goes into which column of the new row.
    • Practical Guidance: First, you select the table columns you want to populate. For each selected column, you must provide a value. You can provide a static value (e.g., typing "In Progress" for a 'Status' column, which will be the same for every new record created) or a dynamic value. To use a dynamic value, you click 'Select a path' to map a specific column from your input Collection (from step 2) to the table column. For instance, you would map the 'Email Address' column from your source data to the 'Contact Email' column in your zenphi Table.
    • Use Case Context: You would use this mapping to ensure that the 'First Name' from your source data correctly populates the 'First Name' column in your destination table for every new record being created.

Outputs

  1. Created Records
    • Data Description: This output provides a single number representing the total count of records that were successfully created in the zenphi Table by the action.
    • Workflow Utility: This count is extremely useful for logging and control flow. You can pass this token to a 'Log Message' action to keep a record of how many rows were added in each run. It is also essential for conditional logic; for example, you can use a condition to check if the 'Created Records' count is greater than zero before proceeding to send a confirmation email, ensuring notifications are only sent when data has actually been added.

Example Use Cases

  1. Bulk Import Spreadsheet Data Migrate data from a Google Sheet or CSV file into a zenphi Table to centralize information and trigger workflows.
  2. Log Form Submissions Capture entries from a Google Form or zenphi Form and create a new record for each submission in a designated logging table.
  3. Sync Data from Other Systems Pull records from an external database or API and add them in bulk to a zenphi Table to maintain data consistency across applications.
  4. Archive Completed Tasks Automatically move a collection of completed tasks from an active project table to a separate archive table for historical record-keeping.

Example

Scenario: An HR department uses a Google Sheet to track all new hires for the upcoming month. At the end of each week, they need to transfer this list into a central "Employee Onboarding" zenphi Table. This transfer initiates various onboarding processes, such as IT setup and welcome emails. Manually copying this data is tedious and prone to errors.

Steps to Implement:

  1. Set up a weekly schedule trigger to run the flow every Friday afternoon.
  2. Add a "Read Rows" action from the Google Sheets connector to fetch all new hire data from the specified spreadsheet. This action will output a collection of rows.
  3. Configure the Create Records action with the following settings:
    • Table: Select the "Employee Onboarding" zenphi Table from the dropdown list.
    • Collection: Use the token picker to select the Rows output from the "Read Rows" action in the previous step.
    • Select fields to create records: Map the columns from the Google Sheet to the fields in the zenphi Table. For example:
      • First Name (Table Column): Select the path for the 'FirstName' column from the input collection.
      • Last Name (Table Column): Select the path for the 'LastName' column from the input collection.
      • Start Date (Table Column): Select the path for the 'StartDate' column from the input collection.
      • Department (Table Column): Select the path for the 'Department' column from the input collection.
  4. Add a "Log Message" action after the Create Records action. Configure it to log the Created Records output token to record how many new employees were successfully added to the table.

Outcome: The process of transferring new hire data is fully automated. Every week, the flow runs, reads the latest data from the Google Sheet, and populates the master "Employee Onboarding" table without any manual intervention. This saves the HR team significant time, eliminates data entry errors, and ensures that downstream onboarding workflows are triggered consistently and immediately.


Best Practices

  1. Ensure Data Consistency: Before running the action, verify that the data types in your source collection (e.g., text, number, date) match the column types in your destination zenphi Table to prevent mapping errors.
  2. Handle Empty Collections: Add a conditional step to check if the input collection from the previous action contains any data. This prevents the flow from running the Create Records action unnecessarily if there are no new records to add.
  3. Use the Output for Auditing: Always use the Created Records output count in a subsequent step, such as a "Log Message" action or by sending a notification email. This creates a clear audit trail and helps confirm that the expected number of records was added.
  4. Map All Required Fields: Double-check that you have mapped all columns in the zenphi Table that are marked as "Required." Failing to provide a value for a required field will cause the action to fail.