create_os_event()

Creates a new server-side scripting event (OsEvent) via dms.CreateOsEvent and returns its id.

1. Signature

  • Sync

  • Async

ecm.system.create_os_event(
    event_code: int | ECMOsEventCode,
    script: str,
    *,
    os_class_name: str | None = None,
    os_event_params: str | None = None,
    app_class: int | ECMOsAppClass | None = None,
) -> int
await ecm.system.create_os_event(
    event_code: int | ECMOsEventCode,
    script: str,
    *,
    os_class_name: str | None = None,
    os_event_params: str | None = None,
    app_class: int | ECMOsAppClass | None = None,
) -> int

2. Parameters

Parameter Type Default Description

event_code

int | ECMOsEventCode

Event trigger. ECMOsEventCode lists well-known codes (e.g. KERNEL_BEFORE_JOB=5000); a plain int is also accepted.

script

str

Executable script code (JavaScript or VBScript, depending on the event type). Stored by the server in the Windows-1252 (cp1252) code page; characters outside cp1252 raise UnicodeEncodeError.

os_class_name

str

None

Target object type: "Application" for application/server-wide events, otherwise the type_id as string. Defaults to application scope when omitted.

os_event_params

str

None

Context parameter whose meaning depends on event_code (field GUID, job name, or library name).

app_class

int | ECMOsAppClass

None

Target platform: CLIENT=1, SERVER=2, WEBCLIENT=3. Inferred from event_code when omitted.

3. Return value

The int id of the newly created event (the id field of an ECMOsEvent). Use it as the handle for update_os_event() and delete_os_event().

4. Examples

4.1. Create a server event

  • Sync

  • Async

from ecmind_blue_client.ecm import ECMOsEventCode

event_id = ecm.system.create_os_event(
    ECMOsEventCode.KERNEL_BEFORE_JOB,
    "'my server script",
    os_class_name="Application",
)
from ecmind_blue_client.ecm import ECMOsEventCode

event_id = await ecm.system.create_os_event(
    ECMOsEventCode.KERNEL_BEFORE_JOB,
    "'my server script",
    os_class_name="Application",
)

5. Important note

These operations access the enaio scripting infrastructure directly. Misconfigured events can disrupt the client or server.

6. See also