Salesforce Work Order Block
A custom Python block that files a Salesforce Work Order, with the evidence image attached, from any Workflow detection.
A detection is only useful if someone goes and fixes the thing. This example is a complete custom Python block that takes what a Workflow just saw, the annotated frame, the model's predictions and the site context, and files it as a Salesforce Work Order with the frame attached under Files. The same block can create a Salesforce Case instead, or POST the payload to a webhook for ServiceNow, Jira or your own middleware.
It works with any Roboflow model output: object detection, instance segmentation, keypoints and classification.
Configurator
Fill in your destination, Salesforce org, severity, site, crew, schedule and SLA hours. The page writes the block code with those values already in it, plus the exact value for every block field in the builder. Nothing you type leaves the page, and the Salesforce token is never part of the output.
If the embed does not load, open the configurator directly: https://roboflow.github.io/workflow-examples/.
How it fits into a Workflow
The block sits at the end of an ordinary detection workflow and consumes what the earlier blocks produce.

Add an Object Detection Model block (or any other model block) and your visualizations.
Add a Custom Python Block, click Edit Code, and paste the code from the configurator.
Declare the inputs and outputs below. Input names must match the parameters of
run.Wire
imageto the visualization output,predictionsto the model, andaccess_tokento a workflow input namedsalesforce_token.

Inputs
image
image
The frame to attach as evidence.
predictions
object_detection_prediction, instance_segmentation_prediction, keypoint_detection_prediction, classification_prediction
Predictions from any model. Select all four kinds.
destination
string
salesforce_work_order, salesforce_case, webhook or dry_run.
destination_config
dictionary
Non-secret settings: instance_url, api_version, extra_fields, webhook url and headers.
access_token
string
Salesforce bearer token. Wire it to a workflow input so it is never stored in the definition.
severity
string
Critical, High, Medium or Low. Drives Priority and the SLA.
alert_type
string
Short machine label such as equipment_fault.
description
string
Human sentence describing what was seen.
site
dictionary
Where: name, zone, asset_id, camera_id, address, lat, lon.
crew
dictionary
Who: skills, headcount, team.
schedule
dictionary
When and what: requested_start, due_by, duration_hours, parts, access_notes, instructions.

Outputs
payload
dictionary
The general work-order payload the block built.
result
dictionary
What the destination answered: status, record id, url, attachment_id.
error_status
boolean
True if anything failed. The block never raises, so the workflow keeps running.
message
string
One line summarizing the outcome.
What it creates
The Work Order gets a Subject built from the alert type and site, Priority from severity, Start Date and End Date from an SLA table, and a Description with the readable summary followed by the full JSON payload. The annotated frame is uploaded as a ContentVersion linked to the record, so it shows under Files.

Authentication
The block sends a bearer token in the Authorization header. For a quick test, use the token from your Salesforce CLI session. For production, create a Connected App with the client credentials flow and a run-as user that can create Work Orders (or Cases) and ContentVersion records.
Keep the token out of the workflow definition. Add a workflow input named salesforce_token, wire the block's access_token field to it, and pass the token at run time, in the builder's Run panel or in the parameters map when you call the workflow:
Adapting it
Everything teams usually change sits at the top of the code: the SLA hours per severity, the default job duration, and the Salesforce fields set on every record. Custom fields that come from the detection itself go in the work_order_fields function, one line per field. A new destination is one more branch in the dispatch function; nothing on the vision side changes.
Run with destination set to dry_run first and inspect the payload output to see exactly what a destination will receive.
Next steps
Custom Blocks - how custom Python blocks run and where.
Dynamic Python blocks - the full reference for the manifest, inputs and outputs, and the
run(...)method.
Last updated
Was this helpful?