move_work_item_to_document
Move a work item into a Polarion document at a specific position, properly setting the module relationship and outline number. This is the only supported method to attach a work item body to a document.
Instructions
Move a work item into a Polarion document at a specific position.
Calls the moveToDocument action endpoint, which updates the work item's
module relationship, inserts a document part at the specified
position, and assigns a proper outline_number — atomically. This
is the ONLY supported way to attach a work item body to a document; editing
homePageContent directly to inject a macro reference leaves the
module relationship unset and produces an inconsistent state.
Heading-type work items are rejected (HTTP 400 "Cannot move
headings"); headings must be created inside their target document.
If the work item is already in a different document, this detaches it from
the source — the operation is a move, not a copy. To detach a work
item back to free-floating (no document), use
move_work_item_from_document — the module relationship
cannot be cleared via PATCH.
Provide AT MOST one of previous_part_id (insert AFTER) /
next_part_id (insert BEFORE); if both are omitted the work item
is appended at the end of the target document. Discover part IDs
with read_document_parts.
Side effect: this server auto-creates an outgoing link from the
moved work item to its enclosing section heading. The role is
project-configurable (commonly parent or relates_to), so
discover it by inspecting forward links on a known-attached work
item in the same project. The auto-link appears in
list_work_item_links(direction="forward") after the move and is
silently removed by move_work_item_from_document. The role
collides with any same-role link created from the same source --
see the "phantom success" note on create_work_item_links.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_id | Yes | Project containing the work item. | |
| work_item_id | Yes | Short ID of an EXISTING work item (e.g. 'MCPT-042'). | |
| target_space_id | Yes | Target space ID (use '_default' for the default space). | |
| target_document_name | Yes | Target document name within ``target_space_id``. | |
| previous_part_id | No | Insert AFTER this part ID; mutually exclusive with ``next_part_id``. Omit both to append at the end of the target document. | |
| next_part_id | No | Insert BEFORE this part ID; mutually exclusive with ``previous_part_id``. Omit both to append at the end of the target document. | |
| dry_run | No | When True, return payload preview without calling Polarion. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| moved | Yes | True on a real move; False on dry-run. | |
| dry_run | Yes | Whether this was a dry-run. | |
| payload_preview | Yes | Request payload sent or previewed; None after real ops. |