cropped-SlicedBread_icon_inversed.png

2.2. Phase 1: Slice (Defining the Source)

This phase determines the source of your data and how it will be broken into “Slices” for processing.

  • The Concept of “Slicing”: Sliced Bread reads the entire data source (the “Bread”) and breaks it into small, independent “Slices.” Each Slice is processed one by one, allowing the engine to handle massive datasets without violating Salesforce governor limits.
  • Available Slice Rules:
    • Slice File Into Lines: The most common rule, used for CSV or TXT files. Each line in the file becomes one Slice.
    • Slice JSON: Parses a JSON file and creates a new Slice for each element in a specified JSON array.
    • Slice XML: Parses an XML file and creates a new Slice for specified XML nodes.
    • Slice Excel: Parses Microsoft Excel files (.xls and .xlsx). This rule includes a wizard to select the specific sheet and configure header rows. (ref: 1.133, 1.135, 1.146)
    • Slice using SOQL: Uses a SOQL query to pull data directly from your Salesforce org. Each record returned by the query becomes a Slice.
    • Slice using Data Aggregation: Behaves like an aggregate SOQL query (e.g., GROUP BY) to create Slices based on grouped data. (ref: 1.82)
    • Slice Generator: Used for data seeding purposes.

2.2.1. Slicing from Inbound Email Attachments #

Both the Slice File Into Lines, Slice JSON, and Slice Excel rules can be configured to process attachments directly from inbound Salesforce emails. This allows for powerful “set it and forget it” automation.

  • Setup: This is configured by setting SlicedBreadInboundEmailHandler as the Apex Class for a Salesforce Email Service.
  • Targeting Files: Within the Slice rule, you can specify a “file name pattern” (e.g., *.csv, invoices_*.xls) to ensure the recipe only processes relevant attachments. (ref: 1.81)
  • Error Handling: The handler is intelligent: if multiple recipes are configured for the same email service, the system will not create a “has no file” error as long as at least one recipe finds a matching file. (ref: 1.192)

Copyright © 2024 all rights reserved, powered by Sliced Bread Software B.V.