workflow_model_by_name()

Returns a runtime-generated, typed model class for a workflow’s input variables — conceptually analogous to ecm.dms.model_by_name. The workflow is resolved via workflow_by_name(), its model read via wfm.GetWorkflow, and the INOUT variable interface mapped to native Python types.

1. Signature

  • Sync

  • Async

ecm.workflow.workflow_model_by_name(
    model_name: str,
    user: ECMOrganisationObjectIdLike,
    client_type: str | ECMClientType,
    organisation: str | ECMOrganisation | None = None,
    *,
    include_internal: bool = False,
) -> type[ECMWorkflowModel]
await ecm.workflow.workflow_model_by_name(
    model_name: str,
    user: ECMOrganisationObjectIdLike,
    client_type: str | ECMClientType,
    organisation: str | ECMOrganisation | None = None,
    *,
    include_internal: bool = False,
) -> type[ECMWorkflowModel]

2. Parameters

Parameter Type Default Description

model_name

str

Workflow model name (see workflow_by_name()).

user

str | ECMOrganisationObject | ECMOrganisationObjectRef

The workflow-organisation user.

client_type

str | ECMClientType

Client type as an ECMClientType, a GUID, or a name. Mandatory.

organisation

str | ECMOrganisation | None

None

Defaults to the active organisation when None.

include_internal

bool

False

When True, internal (non-INOUT) variables are exposed too. Default: input variables only.

3. Return value

An ECMWorkflowModel subclass. Instances are created with the input variables as keyword arguments; values are read/written as attributes and serialised via to_variables() (used internally when starting).

3.1. Type mapping

Server type Python type

STRING

str

INTEGER_SAFE

int

FLOAT_SAFE

float

DATE_SAFE

date

DATETIME_SAFE

datetime

TIME_SAFE

time

ListType

list[…]

RecordType

nested record model (Model.record_model("<name>"))

4. Errors

  • ECMNotFoundException — no workflow with that model name

  • ECMWrongStateException — more than one workflow with that model name

5. Example

Model = ecm.workflow.workflow_model_by_name("test", user, "#OSECM_Client#")

record = Model.record_model("TestRecordVar")(
    StringField="x", IntegerField=1, TimeField="08:00:00",
    DateTimeField="1779365400", FloatField="2.5", StringListField=["inner"],
)
instance = Model(
    StringVar="hello",
    IntegerVar=42,
    StringListVar=["a", "b"],
    TestRecordVar=record,
)

process_id = ecm.workflow.start_process(
    user=user, workflow="test", client_type="#OSECM_Client#", variables=instance,
)

6. Resolve a user by login

The user parameter is the workflow-organisation GUID (not the security login). Resolve it from a login name with ecm.workflow.organisation_user_by_login(login, organisation=None) (matched case-insensitively against the Login attribute; ECMNotFoundException on zero, ECMWrongStateException on several matches):

user = ecm.workflow.organisation_user_by_login("root")
Model = ecm.workflow.workflow_model_by_name("test", user, "#OSECM_Client#")

7. Static models (code generator)

For static typing / IDE completion the models can be generated as .py files — see ecm-generate-workflow-models.

8. See also