AgentSkillsCN

Create update delete records in CRM dataverse

在调用任何 Dataverse/Power Platform MCP 工具之前,请务必阅读【注意事项】——包括获取记录、查询记录、创建记录、更新记录、删除记录等操作。涵盖字段类型、查找语法,以及常见的常见陷阱。触发条件:创建、克隆、更新、删除、关联记录、CRM URL(crm11.dynamics.com),或任何实体操作(联系人、客户、si_*、sic_* 表)。

SKILL.md
--- frontmatter
name: Create update delete records in CRM dataverse
description: "**READ FIRST** before ANY Dataverse/Power Platform MCP tool calls (get-record, query-records, create-record, update-record, delete-record). Covers field types, lookup syntax, and common gotchas. Triggers: create, clone, update, delete, link records, CRM URLs (crm11.dynamics.com), or any entity operations (contacts, accounts, si_*, sic_* tables)."

version: "1.0" author: Klemens Stelk

⚠️ MANDATORY: Read this skill BEFORE using any MCP tools to interact with CRM/Dataverse records. Do not call get-record, query-records, create-record, update-record, or delete-record until you've reviewed this guidance.

Dataverse CRUD Operations

Field Type Reference

Field TypeHow to SetExample
Lookup (single)fieldname@odata.bind"si_titleid@odata.bind": "/si_titles(guid)"
Polymorphic Lookupfieldname_entity@odata.bind"si_customerid_contact@odata.bind": "/contacts(guid)"
Option SetInteger value"sic_joiningreasonsource": 157430003
Two Option (Boolean)true or false"donotemail": false
DateTimeISO 8601 string"birthdate": "1990-05-15"
MoneyDecimal number"revenue": 50000.00
Whole/Decimal NumberInteger or Decimal"numberofemployees": 150
TextString"firstname": "John"

Critical Gotchas

Lookup Fields: Logical Names Work

Both logical names (lowercase) and SchemaNames work—use field names directly from get-record output:

json
{ "si_titleid@odata.bind": "/si_titles(guid)" }

No need to call get-lookup-target for setting lookups.

Polymorphic Lookups Need Entity Suffix

When a lookup can point to multiple entity types:

json
{ "si_customerid_contact@odata.bind": "/contacts(guid)" }
{ "si_customerid_account@odata.bind": "/accounts(guid)" }

Read-Only Fields (Never Set These)

  • createdon, modifiedon, createdby, modifiedby
  • versionnumber, @odata.etag
  • Calculated/rollup fields, fullname on Contact
  • ownerid, owninguser, owningbusinessunit
  • Fields ending in _base (base currency)
  • Fields starting with _ and ending with _value (use @odata.bind instead)

Option Set Values Are Integers

Find values from existing records or metadata—not labels.

Efficient Workflows

Clone a Record

  1. Extract record ID from URL
  2. get-record to retrieve original
  3. create-record with field values (exclude read-only, modify as requested)
  4. If related records needed, create and link via lookups

Avoid: get-entity-metadata, get-lookup-target (not needed)

Create New Record with Specific Values

  1. Identify required lookups (e.g., "title Mr." = need si_title record)
  2. query-records on reference table to find record GUID
  3. create-record with fieldname@odata.bind syntax

Update Existing Record

  1. Extract record ID from URL
  2. update-record with changed fields only (partial update)

Link Records via Lookup

Update the entity with the lookup field:

json
{ "si_emailid@odata.bind": "/si_communicationchannels(email-guid)" }

Common Patterns

Finding Reference Data

javascript
// 1. Query reference table
query-records: si_titles, filter: "contains(si_name, 'Mr')"
// 2. Use GUID in create
{ "si_titleid@odata.bind": "/si_titles(<guid>)" }

Option Set Values

javascript
// Get existing record with correct value set, note the integer
get-record: existing contact with "Events" selected
// Use integer in create
{ "sic_joiningreasonsource": 157430003 }

Error Solutions

ErrorSolution
"Cannot insert duplicate key"Check unique fields (email, external ID, code)
"Lookup attribute is invalid"Verify entity set name and GUID format
"Cannot update read-only field"Remove from payload (ownerid, createdon, etc.)
"Required field missing"Check entity definition or error details
"Invalid type for property"Check field type (string vs int vs boolean)

Pre-Create/Update Checklist

  • Excluded read-only fields
  • Integer values for option sets (not labels)
  • Entity suffix for polymorphic lookups (_contact, _account)
  • Boolean fields use true/false (not 0/1)
  • DateTime in ISO 8601 format
  • Lookups use @odata.bind syntax