The independent daily for Salesforce admins, developers and architects

Curated by Abhinav (opens in a new tab)

Must-read

Advanced PySpark patterns for batch data transforms in Data 360 (opens in a new tab)

Readers will learn how to structure, test, and deploy PySpark Code Extension scripts for complex batch transformations in Data 360.

Why read this

The piece demonstrates three production-ready patterns for hierarchical rollups, JSON event parsing, and machine learning scoring.

  1. Author PySpark script locally using Python SDK
  2. Validate script locally via SF CLI command
  3. Deploy packaged extension to Data 360 org
  4. Execute managed Spark job on demand or schedule
The end-to-end workflow for developing custom batch transforms in Data 360

The article introduces Data 360 Code Extensions as a mechanism to run custom PySpark logic against Data Lake Objects and Data Model Objects within an isolated compute environment. It outlines the full development lifecycle, detailing how engineers use the Salesforce Command Line Interface to validate scripts locally against a sampled dataset before packaging and deploying them to the platform.

The first example implements an iterative loop to calculate total tree revenue across variable-depth account hierarchies by continuously joining frontier records until convergence. The second example provides a reusable helper to parse and explode JSON array columns containing batched session events into individual rows for downstream analytics.

The third example demonstrates how to bundle a serialized scikit-learn classifier and its categorical feature grid to score leads efficiently via a broadcast join. The post concludes by reviewing managed Spark constraints around memory and timeouts, while noting that the transformed outputs become queryable objects for Agentforce agents.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?

Recommended

Use custom Python chunking to improve Agentforce retrieval accuracy in Data 360 (opens in a new tab)

You will learn how to deploy Python-based Code Extension functions to override default chunking in Data 360 search indexes.

Why read this

The guide demonstrates how structure-aware splitting preserves table headers and speaker labels, resulting in more accurate Agentforce responses.

The article argues that poor chunking, not the language model, is often the real cause when an Agentforce agent misses details from a PDF or misreads a conversation, because retrieved snippets lose their context before the model sees them. Native Data 360 chunking (section-aware and semantic passage extraction) works well for standard content, but it struggles with complex multipage PDFs, dense tables and multispeaker transcripts when character or token-based splitters are used. Code Extension functions let developers deploy sandboxed, stateless Python chunking logic inside the Salesforce trust boundary, authored with the Data Custom Code SDK, deployed via the Salesforce CLI or UI, and wired into search index creation. The authors caution that their regex and pattern-based examples are illustrative happy-path code, not production-grade, and can produce false positives and negatives.

The piece tests three scenarios, comparing native chunks with custom ones. In a quarterly financial report, native splitting left numbers stranded without their column headers, making a growth-rate question unanswerable; a structure-aware function that detects table boundaries and repeats headers in sub-chunks lets the agent give a precise segment comparison. In a recorded escalation call with five speakers, native chunking produced unattributed walls of text, while a sliding-window function over speaker turns (window of 6 turns, stride of 3, capped at 1,500 characters) kept questions with their answers and preserved speaker names and timestamps, so the agent could identify a contractual downtime commitment. In a regulated-sector document, native chunking exposed SSNs, card numbers, emails, phone numbers, medical record numbers and other identifiers in the vector index; a regex pass before chunking masked the standard formats, though proprietary identifiers such as medical record, payer member, case and token numbers passed through until organization-specific patterns were added. The conclusion is that Code Extension is an escalation path for complex data rather than a replacement for native chunking, and it points developers to the documentation, the Code Extension setup in Data 360 and a video playlist to get started.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?

Recommended

Deploy Python Code Extensions for complex Data 360 batch transformations (opens in a new tab)

You will learn how to structure, validate, and deploy Python scripts as managed Code Extensions within Data 360.

Why read this

The guide also covers connecting these scripts to batch data transforms and monitoring execution through the platform.

Northstar Outfitters faced inconsistent product data across commerce systems and needed a trusted catalog. Native visual transforms could not handle the required standardization, enrichment, and scoring logic, prompting the use of Data 360 Code Extension to run modular Python and PySpark scripts directly on Salesforce infrastructure.

The solution relies on isolated runtime environments where scripts read from and write to designated Data Lake Objects using explicit permissions defined in a configuration file. Developers validate logic locally against sampled data before packaging the script, dependencies, and tests into a deployable archive.

The guide details both Setup interface and Salesforce CLI workflows for uploading packages, selecting compute sizes, and linking the extension to a batch data transform. Execution, scheduling, and logging are handled by the platform, while operators can trigger runs and review history through REST API calls.

Read the original at Salesforce Developers Blog (opens in a new tab)

Worth reading?