check_insert_permission()

Checks whether an object of a given type may be inserted at a location.

Same wire call as check_permission() with object ID 0, but the object type is mandatory here: it is the type of the object to be inserted, and type 0 is a real folder type rather than a neutral value, so it must never be supplied by default.

1. Signature

  • Sync

  • Async

ecm.dms.check_insert_permission(
    object_type_id: int | str,
    *,
    read: bool = False,
    write: bool = False,
    execute: bool = False,
    delete: bool = False,
    update: bool = False,
    folder_id: int | str | ECMFolderModel | None = None,
    register_id: int | str | ECMRegisterModel | None = None,
    register_type: int | str | None = None,
) -> bool
await ecm.dms.check_insert_permission(
    object_type_id: int | str,
    *,
    read: bool = False,
    write: bool = False,
    execute: bool = False,
    delete: bool = False,
    update: bool = False,
    folder_id: int | str | ECMFolderModel | None = None,
    register_id: int | str | ECMRegisterModel | None = None,
    register_type: int | str | None = None,
) -> bool

2. Parameters

Parameter Type Default Description

object_type_id

int | str

 — 

Numeric type ID of the object to be inserted, as an int or a string holding one.

read

bool

False

Check for read index data permission (R).

write

bool

False

Check for write index data permission (W). This is the flag an insert needs.

execute

bool

False

Check for open/execute permission (X).

delete

bool

False

Check for delete permission (D).

update

bool

False

Check for update object permission (U).

folder_id

int | str | ECMFolderModel | None

None

ID of the target folder, or an ECMFolderModel instance.

register_id

int | str | ECMRegisterModel | None

None

ID of the target register, or an ECMRegisterModel instance.

register_type

int | str | None

None

Type of the target register. 0 means folder level, -1 means register-independent.

At least one of read, write, execute, delete, or update must be True.

3. Return value

True if the insert is permitted, False otherwise. The verdict is read from the Access output parameter exactly as described in How the server reports the verdict.

4. Exceptions

Exception Condition

ValueError

None of the permission flags is True, or object_type_id is not a number.

ECMException

The server reports an error.

5. Examples

5.1. May an invoice document go into this folder?

  • Sync

  • Async

folder = ecm.dms.select(InvoiceFolder).execute()[0]
if ecm.dms.check_insert_permission(327685, write=True, folder_id=folder):
    print("Insert allowed in this folder")
folder = (await ecm.dms.select(InvoiceFolder).execute())[0]
if await ecm.dms.check_insert_permission(327685, write=True, folder_id=folder):
    print("Insert allowed in this folder")

5.2. Check a register location before inserting

  • Sync

  • Async

if ecm.dms.check_insert_permission(327685, write=True, register_id=12345, register_type=196609):
    ecm.dms.insert(InvoiceDocument(Number="2026-0001"), folder_id=98765, register_id=12345)
if await ecm.dms.check_insert_permission(327685, write=True, register_id=12345, register_type=196609):
    await ecm.dms.insert(InvoiceDocument(Number="2026-0001"), folder_id=98765, register_id=12345)

6. See also