Field service data capture form deployer configure

From forcedotcom/sf-skills · View interactive version

Field service data capture form deployer configure is an AI agent skill from the GitHub repository forcedotcom/sf-skills. Assemble a Data Capture Flow from a JSON spec and deploy it to a connected Field Service org via the Tooling Flow sObject (JSON Metadata, no XML). Use when given a data-capture spec JSON and asked to build or deploy a DataCaptureFlow.

How to use this skill

Skill file

Build a Data Capture Form (Field Service Mobile)

This skill takes an intermediate JSON spec and produces a deployed Salesforce Flow with processType=DataCaptureFlow. It assumes the spec is already correct and approved — confirmation with the user happens upstream in the design skills.

Runtime contract: every org interaction in this skill is a REST call

dispatched through the Codey runtime (dispatch locally / the hosted

Headless 360 MCP in shared surfaces). This skill has **no dependency on the

execution environment** — no sf CLI, no shell scripts, no local Python, no

temp files. Auth probes, record reads, and record writes are single REST

calls; the Flow XML is authored by the agent inline from the reference docs.

Do not shell out.

Input contract

A JSON file matching the schema in reference/field-types.md and (optionally) reference/post-screen-automation.md. Canonical examples:

Required top-level keys: formTitle, formType, screens. Optional: postScreen.

Output

A Data Capture Flow created in the org via a single Tooling API call — POST /services/data/vXX.0/tooling/sobjects/Flow with a JSON Metadata body (no .flow-meta.xml, no zip, no SFDX project). The flow is created in Draft status and the user activates it themselves in Flow Builder.

Workflow

1. Verify org auth

Confirm the connected org is reachable with a cheap auth probe — dispatch SELECT Id FROM Organization LIMIT 1 (GET /services/data/vXX.0/query):

2. Pick a Flow API name

If the design skill already supplied <FlowApiName>, use it. Otherwise derive from formTitle: PascalCase, no spaces, must match ^[A-Z][A-Za-z0-9_]*$. If the title can't be coerced, ask the user.

3. Build the Flow Metadata JSON

Assemble the flow's Metadata object inline from the spec — the Tooling Flow sObject takes a JSON Metadata blob, so there is no XML to compile and no converter to run. Follow the JSON shape and field mappings in reference/flow-metadata-json.md and reference/field-types.md.

Notes:

4. Deploy to org

Create the flow with a single Tooling API call — dispatch POST /services/data/vXX.0/tooling/sobjects/Flow with body:

{
  "FullName": "<FlowApiName>",
  "Metadata": { "processType": "DataCaptureFlow", "environments": ["Offline"], "label": "...", "screens": [ ... ], "choices": [ ... ], "variables": [ ... ], "status": "Draft" }
}

5. Report back

On success:

On failure (the POST returned a 400 — read the error from the response body's message):

6. Make the form visible (optional but usually wanted)

Deploying the flow does NOT make it appear in the "Forms" related list on a Service Appointment, Work Order, or other parent. To make a deployed flow show up as a pending form a tech can pick up:

  1. Attach a DynamicDataCapture record to the parent. This is the SDO's canonical "pending form" pattern — see how shipped SDO forms (Job Safety, Vehicle Inspection, Job Completion) are wired. Create the record with a single sObject insert — dispatch POST /services/data/vXX.0/sobjects/DynamicDataCapture with this body:

```json

{

"Name": "<Display Name>",

"ParentRecordId": "<ParentRecordId>",

"ActionDefinition": "<FlowApiName>",

"ActionType": "Flow",

"ProcessType": "DataCaptureFlow",

"StatusCategory": "New",

"IsRequired": true,

"ExecutionOrder": 1

}

```

Name defaults to <FlowApiName> with underscores → spaces if the caller gives no display name; IsRequired is a real boolean (true/false), not a string. A 201 with success: true returns the new DDC id. ParentRecordId is polymorphic — accepted parent types are ServiceAppointment, ServiceResource, TimeSheet, Visit, WorkOrder, WorkOrderLineItem.

  1. For FSL Mobile / Service Appointment context, attach to the parent Work Order, not the SA itself. FSL Mobile's Forms tab on a Service Appointment typically aggregates DynamicDataCapture records from the SA's parent Work Order (via ServiceAppointment.ParentRecordId). Attaching directly to the SA may not surface in mobile.

Resolve the SA's parent Work Order Id first — dispatch GET /services/data/vXX.0/query with SELECT ParentRecordId FROM ServiceAppointment WHERE Id = '<SA_Id>', then attach (sub-step 1) to that Work Order Id.

  1. Verify the parent's page layout has the Forms (DynamicDataCapture) related list. Different SDOs use different layouts per profile. Query with the Tooling API — dispatch GET /services/data/vXX.0/tooling/query with SELECT Layout.Name, Profile.Name FROM ProfileLayout WHERE TableEnumOrId = 'WorkOrder'.

Layout is itself a Tooling sObject with a JSON Metadata field, so the splice is a REST read-modify-write — no XML file, no deploy. Read the layout with GET /services/data/vXX.0/tooling/sobjects/Layout/{layoutId} (resolve {layoutId} from the ProfileLayout.LayoutId in the query above), check Metadata.relatedLists for a DynamicDataCapture entry, and if absent append this entry and PATCH /services/data/vXX.0/tooling/sobjects/Layout/{layoutId} with the updated Metadata:

```json

{

"relatedList": "DynamicDataCapture",

"fields": ["Name", "StatusCategory", "IsRequired"]

}

```

  1. Caveats:
  1. Each profile has its own page layout. Real SDOs commonly route different profiles to different Work Order layouts (e.g. System Administrator → SDO SFS Work Order Layout, Standard User → Work Order Layout, SDO-Service → FSL Work Order Layout). Patching one layout doesn't help users on the others. Run the ProfileLayout query above for every profile that needs to see the form, then patch the union of layouts.
  1. DDC + WorkPlan OWD must be Public Read/Write for FSL Mobile. The Forms tab on FSL Mobile uses the UI API (/ui-api/related-list-records/<woId>/DynamicDataCaptures), which enforces sharing. If DynamicDataCapture or WorkPlan OWD is Private (the platform default), the technician got the WO via AssignedResource sharing and has zero row access to the DDCs themselves — UI API returns INSUFFICIENT_ACCESS and the Forms tab silently shows "No forms available. We couldn't find any forms to display." with a "Try Again" button. Desktop SOQL as admin doesn't catch this because admins bypass sharing.

Fix:

Verify with a Tooling API query — dispatch GET /services/data/vXX.0/tooling/query with SELECT QualifiedApiName, InternalSharingModel FROM EntityDefinition WHERE QualifiedApiName IN ('DynamicDataCapture','WorkPlan'). Both should return ReadWrite. If either returns Private, the Forms tab will fail for the tech even though the DDC row exists.

  1. After attaching, mobile may need a refresh. Even with OWD correct, the FSL Mobile Forms tab caches the related list. To pick up a newly-attached DDC: pull-to-refresh on the Forms tab on the Work Order. Force-quit + reopen the app if pull-to-refresh doesn't surface it. Sign out + back in is only needed when sharing changes (#6).
  1. UI API version note (testing only). UI API v60 returns INSUFFICIENT_ACCESS even after sharing is correct; v62+ works. The iOS FSL Mobile app hardcodes v67, so this isn't a production issue — but it matters when reproducing the call via curl.

Scope

Generated automatically:

Falls back to deploy-safe placeholders (admin replaces in Flow Builder):

See reference/field-types.md for the full mapping.

Out of scope:

Files in this skill

This skill has no executable scripts. Auth checks, record reads, the DynamicDataCapture attach, and the flow create/deploy are all single REST calls dispatched through the Codey runtime (steps 1, 4, 5, 6). The Flow Metadata JSON is assembled by the agent inline (step 3) from the reference docs below.

Related skills

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.