Project Related APIs
Introduction
This how-to describes the APIs that allow users to get information about the current project or document events.
Prerequisites
This how-to uses the results of Get Started with the Web Extensibility API. Complete that how-to before starting this one.
Element Changes API
This API provides events that relate to elements (documents or entities).
documentsChangeddocumentAddedelementsRenamed
| Event | Description | Payload |
|---|---|---|
documentsChanged |
Contains a list of changed documents. | Array of DocumentInfo |
documentAdded |
A single document that was added. | A single DocumentInfo |
elementsRenamed |
Contains a list of renamed elements. | Array of ElementRenameInfo |
DocumentInfo Properties
| Property | Type | Description |
|---|---|---|
documentId |
string | The ID of the document. |
documentType |
string | The type of the document (for example, Microflows$Microflow or myExtension.MyBlobDocument). |
documentName |
string | The name of the document. |
moduleName |
string | Optional name of the containing module. |
ElementRenameInfo Properties
| Property | Type | Description |
|---|---|---|
oldName |
ElementName | The old name of the document. |
newName |
ElementName | The new name of the document. |
documentType |
string | The type of the document (for example, Microflows$Microflow). |
ElementName Properties
| Property | Type | Description |
|---|---|---|
qualifiedName |
string | The qualified name of the document. |
name |
string | The name of the document. |
These events are useful when working with Consistency Checks for Custom Blob Documents.
How to Listen to an Event
studioPro.app.projectChanges.addEventListener("documentsChanged", async ({ documents }) => {
...
}
studioPro.app.projectChanges.addEventListener("documentAdded", async ({ document }) => {
...
}
studioPro.app.projectChanges.addEventListener("elementsRenamed", async ({ elements }) => {
...
}Project Manager API
This API provides events and methods that relate to the current Studio Pro project.
projectOpenedprojectClosinggetProjectMetadata
| Event | Description | Payload |
|---|---|---|
projectOpened |
Triggers when the project is initialized. | ProjectMetadata |
projectClosing |
Triggers when the project is closing, unloading extensions. | ProjectMetadata |
ProjectMetadata Properties
| Property | Type | Description |
|---|---|---|
projectId |
string | The ID of the project. |
projectFile |
string | The file path of the project. |
projectName |
string | The name of the project. |
caption |
string | The description of the project. |
These events are useful when working with Consistency Checks for Custom Blob Documents.
How to Listen to an Event
studioPro.app.projectManager.addEventListener("projectOpened", async ({ project }) => {
...
}
studioPro.app.projectManager.addEventListener("projectClosing", async ({ project }) => {
...
}Getting the Current Project
This API provides a getProjectMetadata method that you can use whenever an extension needs to perform an action requiring an initialized project, such as creating a blob document. It returns a ProjectMetadata object that can also be null.