insertElement Method
Deprecated in 5.1.9 - will not be removed until after 2026-08-04. Use EditTxn.insertElement instead, within an explicit EditTxn scope (or via withEditTxn). See EditTxn documentation for migration help.
Insert a new element into the iModel.
insertElement(elProps: ElementProps, options?: InsertElementOptions): string
@returns The newly inserted element's Id.
@throws ITwinError if insertion fails.
@note For convenience, the value of elProps.id is updated to reflect the resultant element's id.
However when elProps.federationGuid is not present or undefined, a new Guid will be generated and stored on the resultant element. But
the value of elProps.federationGuid is not updated. Generally, it is best to re-read the element after inserting (e.g. via IModelDb.Elements.getElementProps)
if you intend to continue working with it. That will ensure its values reflect the persistent state.
| Parameter | Type | Description |
|---|---|---|
| elProps | ElementProps | The properties of the new element. |
| options | InsertElementOptions |
Returns - string
The newly inserted element's Id.
Defined in
- backend/src/IModelDb.ts Line 2859
Last Updated: 05 May, 2026