insert_variant_and_get()
Combines insert_variant() and get() into a single call: creates a new variant and immediately returns the fully server-populated model instance. Raises ECMException if the server rejects the insert.
ECM Model reference — for a full description of all system properties available on the returned instance.
1. Signature
-
Sync
-
Async
ecm.dms.insert_variant_and_get(
model: T, # bound to ECMDocumentModel
parent_document_id: int | ECMDocumentModel,
files: list[JobRequestFile] | None = None,
*,
same_level: bool | None = None,
set_active: bool | None = None,
transfer_retention: bool | None = None,
check_mandatory: bool = True,
rights: bool = False,
base_params: bool = False,
file_properties: bool = False,
variants: bool = False,
use_result_list: bool = False,
fields: list[str | ECMField] | None = None,
) -> T
await ecm.dms.insert_variant_and_get(
model: T,
parent_document_id: int | ECMDocumentModel,
files: list[JobRequestFile] | None = None,
*,
same_level: bool | None = None,
set_active: bool | None = None,
transfer_retention: bool | None = None,
check_mandatory: bool = True,
rights: bool = False,
base_params: bool = False,
file_properties: bool = False,
variants: bool = False,
use_result_list: bool = False,
fields: list[str | ECMField] | None = None,
) -> T
2. Parameters
2.1. Variant parameters
See insert_variant() for model, parent_document_id, files, same_level, set_active, transfer_retention, and check_mandatory.
2.2. Get parameters
The following parameters are forwarded unchanged to get(). See the get() reference for full details.
| Name | Type | Summary |
|---|---|---|
|
|
Fetch access rights ( |
|
|
Fetch administrative metadata ( |
|
|
Fetch file metadata ( |
|
|
Fetch W-module version branches ( |
|
|
Switch retrieval mode (enables |
|
|
Restrict returned fields. Only effective with |
3. Return value
A typed ECMDocumentModel instance populated with all server-side field values (ID, system fields, index fields).
4. Exceptions
ECMException-
The server rejected the insert (
ObjectID == -1). TypeError-
modelis not anECMDocumentModel. ValueError-
parent_document_idhas noid, orcheck_mandatory=Trueand a required field is missing.
5. Example
-
Sync
-
Async
parent = ecm.dms.get(InvoiceDocument, parent_id)
variant = ecm.dms.insert_variant_and_get(
InvoiceDocument(Title="Revision 2"),
parent,
same_level=True,
set_active=True,
)
print(variant.system.id, variant.Title)
parent = await ecm.dms.get(InvoiceDocument, parent_id)
variant = await ecm.dms.insert_variant_and_get(
InvoiceDocument(Title="Revision 2"),
parent,
same_level=True,
set_active=True,
)
print(variant.system.id, variant.Title)
6. See also
-
insert_variant() — variant-creation only, returns IDs
-
insert_and_get() — non-variant insert