Salesforce B2C Commerce Jobs
Before Writing Code
ALWAYS fetch live documentation BEFORE writing any job code:
- Web-search: "Salesforce B2C Commerce job framework documentation 2026"
- Web-search: "SFCC custom job step implementation guide 2026"
- WebFetch official Salesforce docs for:
- Job framework reference and execution context
- System job types and parameters
- Cron expression syntax for B2C Commerce
- sfcc-ci job command reference
Why: Job APIs, execution contexts, and best practices evolve with each B2C Commerce release. Always verify current patterns.
Conceptual Architecture
Job Framework Overview
The job framework provides scheduled background processing in B2C Commerce:
- Job execution engine: Server-side background task runner
- Job steps: Individual units of work within a job (one job can have multiple steps)
- Job scheduling: Cron-based recurring or manual/API triggering
- Job monitoring: Business Manager dashboard (Administration > Operations > Jobs)
Job Types
| Type |
Description |
Approach |
| System jobs |
Built-in import/export/reindex/cleanup |
Configured in Business Manager |
| Script module steps |
Custom JavaScript (modern approach) |
exports.execute = function(jobStepExecution) {} |
| Pipeline steps |
Legacy pipeline-based steps |
Maintenance mode; avoid for new work |
| Chunk steps |
Large dataset processing |
Read-process-write pattern with commit intervals |
Step Types
| Step Type |
Use Case |
Key Characteristic |
| Script |
General custom logic |
Single execute() entry point; return Status |
| Pipeline |
Legacy flows |
Deprecated for new development |
| Chunk |
Large dataset processing |
Framework manages read/process/write lifecycle with batching |
Cron Expression Examples
0 0 2 * * ? Every day at 2:00 AM
0 */15 * * * ? Every 15 minutes
0 0 0 1 * ? First day of month at midnight
0 0 18 ? * MON-FRI Weekdays at 6:00 PM
Format: seconds minutes hours day-of-month month day-of-week
Status Return Concept
Every job step must return a dw.system.Status object:
| Status |
Constant |
Meaning |
| Success |
Status.OK |
Step completed successfully |
| Error |
Status.ERROR |
Step failed; may halt job depending on configuration |
There is no Status.WARN. For partial success, return Status.OK with a descriptive message (e.g., 'PARTIAL' status code with error count in the message).
// Pattern: Status return
var Status = require('dw/system/Status');
return new Status(Status.OK, 'COMPLETED', 'message');
// Fetch live docs for Status constructor
Chunk Processing Lifecycle
For large datasets, chunk-oriented processing follows this lifecycle:
- Read: Iterator provides next item (or batch of items)
- Process: Transform/validate each item
- Write: Persist results (wrapped in transaction)
- Commit: Framework commits at configured intervals
The framework manages batching, transaction boundaries, and error recovery. Fetch live docs for the exact chunk step interface (read, process, write, afterStep methods).
Job Context and Parameters
Job step parameters are configured in Business Manager per job and accessed at runtime:
jobStepExecution.getParameterValue('ParamName') -- retrieve config values
jobStepExecution.isDisabled() -- check if step is disabled
- Parameter types: String, Number, Boolean, File
System Jobs
| Category |
Examples |
| Import |
Catalog, inventory, pricing, customer data (XML/CSV) |
| Export |
Orders, products, customers |
| Reindex |
Search index rebuild, product availability updates |
| Cleanup |
Session cleanup, log rotation, temp file removal |
Monitoring
- Business Manager: Administration > Operations > Jobs -- execution history, error logs, manual triggering
- sfcc-ci CLI:
sfcc-ci job:run --job-id <id> and sfcc-ci job:status --job-execution-id <id>
- Use
dw/system/Logger for structured logging within job steps
Best Practices
Design Principles
- Make job steps idempotent -- running twice produces the same result (use absolute values, not increments)
- Use chunked processing with
Transaction.wrap() per batch, not per item
- Externalize configuration via job parameters rather than hardcoding values
- Return meaningful
Status messages with item counts and error summaries
Error Handling
- Wrap job logic in try/catch; return
Status.ERROR on failure
- For partial failures, catch per-item errors, accumulate counts, return
Status.OK with descriptive message
- Log errors with
dw/system/Logger including item identifiers for debugging
Transaction Management
- Wrap batch operations in
Transaction.wrap() (per batch, not per item)
- Keep transaction scope minimal to reduce lock contention
- Close iterators (e.g.,
products.close()) in finally blocks to prevent resource leaks
Scheduling and Monitoring
- Schedule resource-intensive jobs during off-peak hours
- Monitor execution times and error rates in Business Manager
- Set up alerts for failed job executions
- Test jobs with small batch sizes before production deployment
Fetch the B2C Commerce job framework reference, cron syntax guide, and sfcc-ci documentation for exact step interfaces, parameter configuration, and chunk processing patterns before implementing.
1---2name: sf-b2c-jobs3description: Build and manage B2C Commerce jobs — job framework, job steps (script modules, pipelines, custom), scheduling with cron expressions, job context and parameters, import/export jobs, reindex jobs, and Business Manager monitoring. Use when implementing background processing in B2C Commerce.4allowed-tools: Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch5metadata:6 source: https://skillmd.com/skills/orcaqubits/sf-b2c-jobs7---89# Salesforce B2C Commerce Jobs1011## Before Writing Code1213**ALWAYS fetch live documentation BEFORE writing any job code:**14151. Web-search: "Salesforce B2C Commerce job framework documentation 2026"162. Web-search: "SFCC custom job step implementation guide 2026"173. WebFetch official Salesforce docs for:18 - Job framework reference and execution context19 - System job types and parameters20 - Cron expression syntax for B2C Commerce21 - sfcc-ci job command reference2223**Why:** Job APIs, execution contexts, and best practices evolve with each B2C Commerce release. Always verify current patterns.2425## Conceptual Architecture2627### Job Framework Overview2829The job framework provides scheduled background processing in B2C Commerce:30- **Job execution engine**: Server-side background task runner31- **Job steps**: Individual units of work within a job (one job can have multiple steps)32- **Job scheduling**: Cron-based recurring or manual/API triggering33- **Job monitoring**: Business Manager dashboard (Administration > Operations > Jobs)3435### Job Types3637| Type | Description | Approach |38|------|-------------|----------|39| **System jobs** | Built-in import/export/reindex/cleanup | Configured in Business Manager |40| **Script module steps** | Custom JavaScript (modern approach) | `exports.execute = function(jobStepExecution) {}` |41| **Pipeline steps** | Legacy pipeline-based steps | Maintenance mode; avoid for new work |42| **Chunk steps** | Large dataset processing | Read-process-write pattern with commit intervals |4344### Step Types4546| Step Type | Use Case | Key Characteristic |47|-----------|----------|--------------------|48| **Script** | General custom logic | Single `execute()` entry point; return `Status` |49| **Pipeline** | Legacy flows | Deprecated for new development |50| **Chunk** | Large dataset processing | Framework manages read/process/write lifecycle with batching |5152### Cron Expression Examples5354```550 0 2 * * ? Every day at 2:00 AM560 */15 * * * ? Every 15 minutes570 0 0 1 * ? First day of month at midnight580 0 18 ? * MON-FRI Weekdays at 6:00 PM59```6061Format: `seconds minutes hours day-of-month month day-of-week`6263### Status Return Concept6465Every job step must return a `dw.system.Status` object:6667| Status | Constant | Meaning |68|--------|----------|---------|69| Success | `Status.OK` | Step completed successfully |70| Error | `Status.ERROR` | Step failed; may halt job depending on configuration |7172There is **no `Status.WARN`**. For partial success, return `Status.OK` with a descriptive message (e.g., `'PARTIAL'` status code with error count in the message).7374```javascript75// Pattern: Status return76var Status = require('dw/system/Status');77return new Status(Status.OK, 'COMPLETED', 'message');78// Fetch live docs for Status constructor79```8081### Chunk Processing Lifecycle8283For large datasets, chunk-oriented processing follows this lifecycle:84851. **Read**: Iterator provides next item (or batch of items)862. **Process**: Transform/validate each item873. **Write**: Persist results (wrapped in transaction)884. **Commit**: Framework commits at configured intervals8990The framework manages batching, transaction boundaries, and error recovery. Fetch live docs for the exact chunk step interface (`read`, `process`, `write`, `afterStep` methods).9192### Job Context and Parameters9394Job step parameters are configured in Business Manager per job and accessed at runtime:95- `jobStepExecution.getParameterValue('ParamName')` -- retrieve config values96- `jobStepExecution.isDisabled()` -- check if step is disabled97- Parameter types: String, Number, Boolean, File9899### System Jobs100101| Category | Examples |102|----------|---------|103| **Import** | Catalog, inventory, pricing, customer data (XML/CSV) |104| **Export** | Orders, products, customers |105| **Reindex** | Search index rebuild, product availability updates |106| **Cleanup** | Session cleanup, log rotation, temp file removal |107108### Monitoring109110- **Business Manager**: Administration > Operations > Jobs -- execution history, error logs, manual triggering111- **sfcc-ci CLI**: `sfcc-ci job:run --job-id <id>` and `sfcc-ci job:status --job-execution-id <id>`112- Use `dw/system/Logger` for structured logging within job steps113114## Best Practices115116### Design Principles117- Make job steps **idempotent** -- running twice produces the same result (use absolute values, not increments)118- Use **chunked processing** with `Transaction.wrap()` per batch, not per item119- Externalize configuration via **job parameters** rather than hardcoding values120- Return meaningful `Status` messages with item counts and error summaries121122### Error Handling123- Wrap job logic in try/catch; return `Status.ERROR` on failure124- For partial failures, catch per-item errors, accumulate counts, return `Status.OK` with descriptive message125- Log errors with `dw/system/Logger` including item identifiers for debugging126127### Transaction Management128- Wrap batch operations in `Transaction.wrap()` (per batch, not per item)129- Keep transaction scope minimal to reduce lock contention130- Close iterators (e.g., `products.close()`) in finally blocks to prevent resource leaks131132### Scheduling and Monitoring133- Schedule resource-intensive jobs during off-peak hours134- Monitor execution times and error rates in Business Manager135- Set up alerts for failed job executions136- Test jobs with small batch sizes before production deployment137138Fetch the B2C Commerce job framework reference, cron syntax guide, and sfcc-ci documentation for exact step interfaces, parameter configuration, and chunk processing patterns before implementing.