Retrieves a model instance (such as BlockModel, PageModel, ActionModel, etc.) from the current engine or view stack based on the model uid. This is used in RunJS to access other models across blocks, pages, or popups.
If you only need the model or block where the current execution context is located, prioritize using ctx.model or ctx.blockModel instead of ctx.getModel.
| Scenario | Description |
|---|---|
| JSBlock / JSAction | Get models of other blocks based on a known uid to read or write their resource, form, setProps, etc. |
| RunJS in Popups | When needing to access a model on the page that opened the popup, pass searchInPreviousEngines: true. |
| Custom Actions | Locate forms or sub-models in the configuration panel by uid across view stacks to read their configuration or state. |
| Parameter | Type | Description |
|---|---|---|
uid | string | The unique identifier of the target model instance, specified during configuration or creation (e.g., ctx.model.uid). |
searchInPreviousEngines | boolean | Optional, defaults to false. When true, searches from the current engine up to the root in the "view stack," allowing access to models in upper-level engines (e.g., the page that opened a popup). |
FlowModel subclass instance (e.g., BlockModel, FormBlockModel, ActionModel) if found.undefined if not found.searchInPreviousEngines: false): Searches only within the current engine by uid. In popups or multi-level views, each view has an independent engine; by default, it only searches for models within the current view.searchInPreviousEngines: true: Searches upwards along the previousEngine chain starting from the current engine, returning the first match. This is useful for accessing a model on the page that opened the current popup.getModel.