forcedotcom/sf-skills

field-service-sobject-create-configure

Headless 360 REST API deployment step for creating sObject records.

查看源码

使用方法

  1. 复制安装命令,在自己的智能体环境安装前先检查源码包。
  2. 从原始文档核对所需工具、凭据和支持的宿主。
  3. 说明输入材料与期望交付物,并对照来源检查输出。
npx skills add https://github.com/forcedotcom/sf-skills --skill field-service-sobject-create-configure

开始前需了解

  • 安装不包含模型订阅、API 额度或访问文件的权限。
  • 仓库星数和安装量反映活跃情况,不等于独立质量或安全测试。
仓库原始内容

按源仓库内容呈现,保留标题、案例、代码、表格、链接以及原文引用的演示图片。

Managing Sfs Sobject Create

When to Use This Skill

Create sObject records via Headless 360 REST API. Describes the flow (describe → query → create), Field Service data model DAG, field requirements, insertion order, and common pitfalls. Reference when creating Skill, WorkType, SkillRequirement, or other Field Service sObjects.

Workflow

Create an sObject record via headless-360

Be helpful — understand business context before creating records. Consider the business domain of the sObject being created and iterate through short, structured questions (ask/why/impact) until no ambiguities remain that would change what gets created. Skip questions when answers are already obvious from context or existing data.

Flow

Phase 1: Describe — dispatch_readonly GET /services/data/v67.0/sobjects/<SObject>/describe

Phase 2: Query existing records — learn the org's shape...

dispatch_readonly GET /services/data/v67.0/query, queryParams.q = "SELECT <required + picklist fields> FROM <SObject> ORDER BY CreatedDate DESC LIMIT 20". Use it to: match naming/value conventions, see which optional fields are actually populated, catch duplicates, and confirm write access before spending a create.

Phase 3: Create — dispatch POST to create records. Single...

Data model DAG

Example (Field Service junction pattern — same pattern applies to any sObject DAG based on the data shape):

text
Skill (0C5)    WorkType (08q)    ← roots (parallel)
    └──────────┬──────────┘
       SkillRequirement (0Hx)     ← junction (last)

Fields and insertion order

Scan describe fields[] for createable:true (skip the rest — describe is large). Such a field is required when also nillable:false and defaultedOnCreate:false (defaulted ones the platform fills — omit). Two kinds:

  • Scalar → put its value in the create body.
  • `type:"reference"` → foreign key. If nillable:false (hard edge), create parent in referenceTo[] first. Polymorphic refs list many — pick one. Topo-sort: roots first, pass each id to dependents. nillable:true refs → optional, PATCH later.

Pitfalls:

  • Base sObject CRUD is NOT in the discover corpus — skip discover, go straight to describe → dispatch.
  • CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY on write → that sObject blocks sObject-REST writes

(e.g. ExternalDataSource, CustomPermission); use Tooling/Metadata API instead.

  • 400/403 → likely a CRUD/FLS/sharing gap for the gateway user, not a payload bug — don't blindly retry the body.

Example — WorkType

Describe WorkType, apply the rule to fields[]. The fields that come back createable:true, nillable:false, defaultedOnCreate:false are the required ones — build the body from those, don't assume field names. Then query a few existing WorkTypes to see conventions and dupes. Then create with the derived body, e.g.

json
{ "url": "/services/data/v67.0/sobjects/WorkType", "method": "POST",
  "body": { "Name": "Standard Repair", "EstimatedDuration": 2 } }

───── Runtime context (Headless 360 / agentic): When this skill runs in the Headless 360 / agentic context, prefer the platform dispatch tool (`dispatch in the hosted Headless 360 MCP; dispatch in the local-dev MCP) over CLI tools (sf project deploy, sfdx, shell commands) when possible. The operations available to you are listed below in steps:`; each has been verified against the live org. Call the dispatch tool against the canonical paths. CLI fallback is acceptable only when no API path exists for a given capability.

Critical Constraints

Preconditions:

  • Target sObject is createable and not on the sObject-REST block list. (check: GET /services/data/v67.0/sobjects/{N}/describe returns createable: true at the top level. A CANNOTINSERTUPDATEACTIVATEENTITY on POST means the sObject blocks base REST writes (e.g. ExternalDataSource, CustomPermission) — switch to Tooling or Metadata API.)
  • Gateway user has object CRUD + relevant FLS for the required createable fields. (check: 400 / 403 with INSUFFICIENTACCESSOR_READONLY on POST → CRUD/FLS gap, not a payload bug. Grant the user's profile / permset the Create on the entity and Edit-access on every field in the body.)
  • For composite/graph transactions, the caller has independently topo-sorted parents before children within each graph node's records. (check: `referenceIds used with @{...} MUST refer to a record earlier in the same graph. Wrong ordering surfaces as INVALID_REFERENCE_ID on the child node, and the entire graph rolls back atomically.`)

Operations Reference

Operations grouped by purpose. Use these as the building blocks for the workflows above.

Summary

OperationPurposeStatusCallDepends on
describe-sobjectread—GET /services/data/v67.0/sobjects/{SObjectName}/describe—
query-existing-recordsread—GET /services/data/v67.0/querydescribe-sobject
create-sobject-recordwrite—POST /services/data/v67.0/sobjects/{SObjectName}describe-sobject
composite-graph-createwrite—POST /services/data/v67.0/composite/graphdescribe-sobject
update-sobject-recordwrite—PATCH /services/data/v67.0/sobjects/{SObjectName}/{Id}create-sobject-record
delete-sobject-recordwrite—DELETE /services/data/v67.0/sobjects/{SObjectName}/{Id}—

Dependency graph

mermaid
graph TD
  describe_sobject["describe-sobject (read)"]
  query_existing_records["query-existing-records (read)"]
  create_sobject_record["create-sobject-record (write)"]
  composite_graph_create["composite-graph-create (write)"]
  update_sobject_record["update-sobject-record (write)"]
  delete_sobject_record["delete-sobject-record (write)"]
  describe_sobject --> query_existing_records
  describe_sobject --> create_sobject_record
  describe_sobject --> composite_graph_create
  create_sobject_record --> update_sobject_record

Read operations

describe-sobject

Fetch the field catalog for {SObjectName}. Scan fields[] for createable:true; hard-required fields are those also with nillable:false and defaultedOnCreate:false. type:"reference" fields are FKs — hard edges when nillable:false. Base sObject CRUD is intentionally OUT of the discover corpus (skill §Pitfalls); agents must skip discover and call describe directly.

Call: GET /services/data/v67.0/sobjects/{SObjectName}/describe

Inputs:

  • SObjectName (`string`) — API name of the sObject (e.g. WorkType, Skill, SkillRequirement). Path segment.

Output: SObjectDescribeSObjectResult. Load-bearing keys: createable, updateable, deletable, fields[] (each with name, type, createable, nillable, defaultedOnCreate, referenceTo[], picklistValues[]). Payload is large (>60KB for WorkType) — filter to createable:true fields before reasoning.

query-existing-records

Warm-read a small window of existing rows to match naming conventions, spot dupes, and confirm write access before spending a create. Skill §Flow.2 suggested SOQL: SELECT <required + picklist fields> FROM <SObject> ORDER BY CreatedDate DESC LIMIT 20.

Call: GET /services/data/v67.0/query

Inputs:

  • q (`string`) — SOQL query. Pass via queryParams.q (URL-encoded on the wire). LIMIT 20 or fewer is the recommended window for convention scanning.

Depends on: describe-sobject

Output: {totalSize, done, records: [<row>]}. records[] is the shape an agent scans for conventions. done:false + nextRecordsUrl surface when > 200 rows — irrelevant at LIMIT 20.

Write operations

create-sobject-record

Create ONE record. Body carries only fields that were createable:true on describe. For DAGs (parents + children + junctions), prefer composite/graph so all rows land atomically in one transaction. 201 → {id, success, errors:[]}; non-2xx returns [{errorCode, message, fields:[]}].

Call: POST /services/data/v67.0/sobjects/{SObjectName}

Inputs:

  • SObjectName (`string`) — API name of the sObject (path segment).
  • body (`object`) — Field/value map. Only include fields with createable:true on describe; omit defaultedOnCreate:true fields (the platform fills them).

Depends on: describe-sobject

Output: 201 → {id: "<15/18-char id>", success: true, errors: []}. 4xx → array of {errorCode, message, fields}.

Rollback: delete-sobject-record

Notes: ERROR CONTRACT:

  • CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY → sObject blocks base

REST writes; switch to Tooling / Metadata API. Common for ExternalDataSource, CustomPermission.

  • INSUFFICIENT_ACCESS_OR_READONLY → CRUD/FLS/sharing gap on

the gateway user; don't retry the same body.

  • REQUIRED_FIELD_MISSING → re-check describe filter (some

fields are createable+nillable:false only in specific record types).

  • INVALID_FIELD_FOR_INSERT_UPDATE → field is not

createable:true; drop from body.

composite-graph-create

Atomically create a DAG of related records in one transaction. Skill §Data-model-DAG example: Skill + WorkType (roots) → SkillRequirement (junction). Use referenceId on each record and @{parentRef.id} in a child's FK field to bind at write time. Success returns 200 with per-node compositeResponse[] entries carrying per-child 201s. Any failure rolls back the ENTIRE graph.

Call: POST /services/data/v67.0/composite/graph

Inputs:

  • body (`object`) — `{graphs: [{graphId, compositeRequest: [{referenceId,

method:"POST", url:"/services/data/v67.0/sobjects/<N>", body:{...}}, ...]}]}`. Multiple graphs may share one call; each isolates atomicity.

Depends on: describe-sobject

Output: 200 → {graphs: [{graphId, graphResponse: {compositeResponse: [{body:{id, success, errors}, httpHeaders, httpStatusCode, referenceId}]}, isSuccessful}]}. isSuccessful:false + per-child 4xx bodies on any failure.

Rollback: delete-sobject-record

Notes: ERROR CONTRACT:

  • INVALID_REFERENCE_ID → child references a referenceId

that appears LATER in the array or doesn't exist. Topo-sort the compositeRequest[] parents-first.

  • LIMIT_EXCEEDED → composite/graph caps at 500 records per

graph and 75 graphs per call.

  • MIXED_DML_OPERATION → **the graph mixes setup-object

sObjects (e.g. Skill, Group, User, Permission*) with non-setup sObjects (e.g. WorkType, Account, Contact) in one transaction — the platform forbids this even inside composite/graph.** Split into two calls: create setup-side in call 1, capture the id, then create non-setup-side + junction referencing that id in call 2. The skill's Skill+WorkType+SkillRequirement example REQUIRES this split.

  • Any HTTP 4xx on ANY child → the graph's entire

compositeResponse rolls back; sibling children report PROCESSING_HALTED and DELETE cleanup is unnecessary for a failed graph.

update-sobject-record

Field-level update on an existing record. Use for late-bound nillable:true reference attachment (skill §Fields-and- insertion-order) or corrections. PATCH is field-merge, not full-replacement: only fields in the body change; omitted fields are untouched. 204 on success (no response body).

Call: PATCH /services/data/v67.0/sobjects/{SObjectName}/{Id}

Inputs:

  • SObjectName (`string`)
  • Id (`string`) — 15- or 18-char record id (path segment).
  • body (`object`) — Field/value map. Only include fields with updateable:true on describe.

Depends on: create-sobject-record

Output: 204 No Content on success. 4xx → same [{errorCode, message, fields}] shape as POST.

delete-sobject-record

Delete a record. Rollback target for create-sobject-record (single) and composite-graph-create (children where the transaction succeeded but a downstream verify failed). 204 on success. Note: composite/graph atomically rolls back on failure — DELETE is only needed after a SUCCESSFUL graph that a later validation rejects.

Call: DELETE /services/data/v67.0/sobjects/{SObjectName}/{Id}

Inputs:

  • SObjectName (`string`)
  • Id (`string`)

Output: 204 No Content. 404 → id already gone (idempotent); treat as success.

按任务相关推荐

来自同一仓库

更多 Skills

全部 Skills
forcedotcom
社区

platform-custom-application-generate

Use this skill when users need to create or configure tab-based Salesforce Custom Applications with navigation, branding, and action overrides. Trigger when users mention custom apps, application metadata, app navigation, or organizing tabs into applications. Use when users want to create app containers for tabs and pages. Do NOT use when the goal is hosting a React UI bundle in the App Launcher — use experience-ui-bundle-custom-app-generate for that case.

安装量
1
GitHub Stars
1112
最近更新
10月23日
forcedotcom
社区

platform-custom-field-generate

Use when users create, generate, or validate Salesforce Custom Field metadata. Trigger on custom fields, field types, Roll-Up Summary, Master-Detail/Lookup relationships, formula fields, picklists, dependent (controlling) picklists, referencing a value set from a field, or scoping picklist values per record type; also field deployment errors, including a record type that won't deploy without a business process. DO NOT TRIGGER for creating/customizing the value set itself — a new GlobalValueSet o

安装量
1
GitHub Stars
1112
最近更新
10月23日
forcedotcom
社区

platform-custom-metadata-type-generate

Use to create, generate, or validate Salesforce Custom Metadata Type metadata — the mdt object, fields, and deployable records. Trigger on custom metadata types, CMDT, mdt objects, .md-meta.xml files, or cross-org reference/config data; also admin-maintained mapping/lookup/crosswalk tables (config that changes without a deploy belongs in a CMDT, never hardcoded in Apex/Flow), and CMDT deploy errors. DO NOT TRIGGER for Custom Settings (use platform-custom-setting-generate), business-record object

安装量
1
GitHub Stars
1112
最近更新
10月23日
forcedotcom
社区

platform-custom-report-type-generate

Use to create, generate, or validate Salesforce Custom Report Type metadata. Trigger on custom report types, CRTs, cross-object reports, report builder data sources, exposing fields for reporting across related objects, inner vs outer joins in reports, report type categories, or deployment errors for .reportType-meta.xml files. Do NOT trigger for running, editing, or filtering existing reports; creating report folders, dashboards, or list views; or non-authoring reporting questions.

安装量
1
GitHub Stars
1112
最近更新
10月23日