AgentSkillsCN

1c-form-compile

向现有的1C托管表单(Form.xml)中添加元素、属性与命令。当您希望通过插入新的UI元素、数据属性或命令来修改现有表单时,此功能将助您事半功倍。

SKILL.md
--- frontmatter
name: 1c-form-compile
description: "Compile a 1C managed form (Form.xml) from a compact JSON definition. Use when generating Form.xml from a JSON DSL for any 1C object — data processors, documents, catalogs, registers, etc."

1C Form Compile — Generate Form.xml from JSON DSL

Takes a compact JSON definition (20–50 lines) and generates a complete, valid Form.xml (100–500+ lines) with namespace declarations, auto-generated companion elements, and sequential IDs.

When designing a form from scratch (5+ elements or unclear requirements) — load the 1c-form-patterns skill first for archetypes, naming conventions, and advanced patterns. For simple forms (1–3 fields with clear requirements) — not needed.

Usage

code
1c-form-compile <JsonPath> <OutputPath>
ParameterRequiredDescription
JsonPathyesPath to the form JSON definition
OutputPathyesPath to output Form.xml file

Command

powershell
powershell.exe -NoProfile -File skills/1c-form-compile/scripts/form-compile.ps1 -JsonPath "<json>" -OutputPath "<xml>"

JSON DSL Reference

Top-Level Structure

json
{
  "title": "Form Title",
  "properties": { "autoTitle": false, ... },
  "events": { "OnCreateAtServer": "OnCreateAtServerHandler" },
  "excludedCommands": ["Reread"],
  "elements": [ ... ],
  "attributes": [ ... ],
  "commands": [ ... ],
  "parameters": [ ... ]
}
  • title — form title (multilingual). Can also be in properties, but top-level is preferred
  • properties — form properties: autoTitle, windowOpeningMode, commandBarLocation, saveDataInSettings, width, height, etc.
  • events — form event handlers (key: 1C event name, value: procedure name)
  • excludedCommands — excluded standard commands

Elements (key determines type)

DSL KeyXML ElementKey Value
"group"UsualGroup"horizontal" / "vertical" / "alwaysHorizontal" / "alwaysVertical" / "collapsible"
"input"InputFieldelement name
"check"CheckBoxFieldname
"label"LabelDecorationname (text set via title)
"labelField"LabelFieldname
"table"Tablename
"pages"Pagesname
"page"Pagename
"button"Buttonname
"picture"PictureDecorationname
"picField"PictureFieldname
"calendar"CalendarFieldname
"cmdBar"CommandBarname
"popup"Popupname

Common Properties (all element types)

KeyDescription
nameOverride name (default = type key value)
titleElement title
visible: falseHide (synonym: hidden: true)
enabled: falseDisable (synonym: disabled: true)
readOnly: trueRead-only
on: [...]Events with auto-named handlers
handlers: {...}Explicit handler names: {"OnChange": "MyHandler"}

Allowed Event Names (on)

The compiler warns about unknown events. Names are case-sensitive — use exactly as shown.

Form (events): OnCreateAtServer, OnOpen, BeforeClose, OnClose, NotificationProcessing, ChoiceProcessing, OnReadAtServer, BeforeWriteAtServer, OnWriteAtServer, AfterWriteAtServer, BeforeWrite, AfterWrite, FillCheckProcessingAtServer, BeforeLoadDataFromSettingsAtServer, OnLoadDataFromSettingsAtServer, ExternalEvent, Opening

input / picField: OnChange, StartChoice, ChoiceProcessing, AutoComplete, TextEditEnd, Clearing, Creating, EditTextChange

check: OnChange

table: OnStartEdit, OnEditEnd, OnChange, Selection, ValueChoice, BeforeAddRow, BeforeDeleteRow, AfterDeleteRow, BeforeRowChange, BeforeEditEnd, OnActivateRow, OnActivateCell, Drag, DragStart, DragCheck, DragEnd

label / picture: Click, URLProcessing

labelField: OnChange, StartChoice, ChoiceProcessing, Click, URLProcessing, Clearing

button: Click

pages: OnCurrentPageChange

Input Field

KeyDescriptionExample
pathDataPath — data binding"Object.Organization"
titleLocationTitle location"none", "left", "top"
multiLine: trueMulti-line fieldtext field, comment
passwordMode: truePassword mode (asterisks)password input
choiceButton: trueChoice button ("...")reference field
clearButton: trueClear button ("X")
spinButton: trueSpin buttonnumeric fields
dropListButton: trueDrop-down list button
markIncomplete: trueMark as incompleterequired fields
skipOnInput: trueSkip on Tab traversal
inputHintHint in empty field"Enter name..."
width / heightSizenumbers
autoMaxWidth: falseDisable auto-widthfor fixed fields
horizontalStretch: trueStretch horizontally

Checkbox

KeyDescription
pathDataPath
titleLocationTitle location

Label Decoration

KeyDescription
titleLabel text (required)
hyperlink: trueMake it a hyperlink
width / heightSize

Group

Value of the key sets orientation: "horizontal", "vertical", "alwaysHorizontal", "alwaysVertical", "collapsible".

KeyDescription
showTitle: trueShow group title
united: falseDo not unite border
representation"none", "normal", "weak", "strong"
children: [...]Nested elements

Table

Important: a table requires an associated form attribute of type ValueTable with columns (see "Bindings" section).

KeyDescription
pathDataPath (binding to table attribute)
columns: [...]Columns — array of elements (usually input)
changeRowSet: trueAllow adding/removing rows
changeRowOrder: trueAllow row reordering
heightHeight in table rows
header: falseHide header
footer: trueShow footer
commandBarLocation"None", "Top", "Auto"
searchStringLocation"None", "Top", "Auto"

Pages (pages + page)

Key (pages)Description
pagesRepresentation"None", "TabsOnTop", "TabsOnBottom", etc.
children: [...]Array of page elements
Key (page)Description
titleTab title
groupOrientation inside page
children: [...]Page content

Button

KeyDescription
commandForm command name → Form.Command.Name
stdCommandStandard command: "Close"Form.StandardCommand.Close; with dot: "Items.Add"Form.Item.Items.StandardCommand.Add
defaultButton: trueDefault button
type"usual", "hyperlink", "commandBar"
pictureButton picture
representation"Auto", "Text", "Picture", "PictureAndText"
locationInCommandBar"Auto", "InCommandBar", "InAdditionalSubmenu"

Command Bar (cmdBar)

KeyDescription
autofill: trueAuto-fill with standard commands
children: [...]Bar buttons

Popup Menu

KeyDescription
titleSubmenu title
children: [...]Submenu buttons

Used inside cmdBar to group buttons:

json
{ "cmdBar": "Panel", "children": [
  { "popup": "Add", "title": "Add", "children": [
    { "button": "AddRow", "stdCommand": "Items.Add" },
    { "button": "AddFromDocument", "command": "AddFromDocument", "title": "From Document" }
  ]}
]}

Attributes

json
{ "name": "Object", "type": "DataProcessorObject.Import", "main": true }
{ "name": "Total", "type": "decimal(15,2)" }
{ "name": "Table", "type": "ValueTable", "columns": [
    { "name": "Product", "type": "CatalogRef.Products" },
    { "name": "Quantity", "type": "decimal(10,3)" }
]}
  • savedData: true — saved data

Commands

json
{ "name": "Import", "action": "ImportHandler", "shortcut": "Ctrl+Enter" }
  • title — title (if different from name)
  • picture — command picture

Type System

DSLXML
"string" / "string(100)"xs:string + StringQualifiers
"decimal(15,2)"xs:decimal + NumberQualifiers
"decimal(10,0,nonneg)"with AllowedSign=Nonnegative
"boolean"xs:boolean
"date" / "dateTime" / "time"xs:dateTime + DateFractions
"CatalogRef.XXX"cfg:CatalogRef.XXX
"DocumentRef.XXX"cfg:DocumentRef.XXX
"ValueTable"v8:ValueTable
"ValueList"v8:ValueListType
"Type1 | Type2"composite type

Bindings: Element + Attribute

Tables and some fields require an associated attribute. Elements reference attributes via path.

Tabletable element + ValueTable attribute:

json
{
  "elements": [
    { "table": "Items", "path": "Object.Items", "columns": [
      { "input": "Product", "path": "Object.Items.Product" }
    ]}
  ],
  "attributes": [
    { "name": "Object", "type": "DataProcessorObject.Import", "main": true,
      "columns": [
        { "name": "Items", "type": "ValueTable", "columns": [
          { "name": "Product", "type": "CatalogRef.Products" }
        ]}
      ]
    }
  ]
}

Or, if table is bound to a form attribute (not Object):

json
{
  "elements": [
    { "table": "DataTable", "path": "DataTable", "columns": [
      { "input": "Name", "path": "DataTable.Name" }
    ]}
  ],
  "attributes": [
    { "name": "DataTable", "type": "ValueTable", "columns": [
      { "name": "Name", "type": "string(150)" }
    ]}
  ]
}

Auto-generation

  • Companion elements: ContextMenu, ExtendedTooltip, etc. are created automatically
  • Event handlers: "on": ["OnChange"] → auto-named handler
  • Namespace: all 17 namespace declarations
  • IDs: sequential numbering, AutoCommandBar = id="-1"
  • Unknown keys: warning about unrecognized keys

Verification

code
1c-form-validate <OutputPath>    — check XML correctness
1c-form-info <OutputPath>        — visual structure summary

Notes for External Data Processors (EPF)

  • Main attribute type: ExternalDataProcessorObject.ProcessorName (not DataProcessorObject)
  • DataPath: use form attributes (AttributeName), not Object.AttributeName — external data processors have no object attributes in metadata
  • Reference types: CatalogRef.XXX, DocumentRef.XXX, etc. may not build in an empty infobase — use string or basic types for standalone builds

MCP Integration

Use search_metadata MCP tool to verify metadata types when defining attributes. Use templatesearch to find similar form patterns.