# Trigger a model file save from within a Camunda Modeler Plugin

**URL:** <https://forum.bpmn.io/t/trigger-a-model-file-save-from-within-a-camunda-modeler-plugin/6423>\
**Category:** Users\
**Created:** [July 1, 2021, 9:53am UTC](https://forum.bpmn.io/t/trigger-a-model-file-save-from-within-a-camunda-modeler-plugin/6423 "2021-07-01T09:53:22Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![berndruecker](https://forum.bpmn.io/user_avatar/forum.bpmn.io/berndruecker/32/2938_2.png) [@berndruecker](https://forum.bpmn.io/u/berndruecker)\
**Post date:** [July 1, 2021, 9:53am UTC](https://forum.bpmn.io/t/trigger-a-model-file-save-from-within-a-camunda-modeler-plugin/6423/1 "2021-07-01T09:53:22Z")

</div>

Hey folks.

I want to trigger “save” for the current tab within a Camunda Modeler Plugin. I tried looking into [camunda-modeler-autosave-plugin/AutoSavePlugin.js at main · pinussilvestrus/camunda-modeler-autosave-plugin · GitHub](https://github.com/pinussilvestrus/camunda-modeler-autosave-plugin/blob/main/client/AutoSavePlugin.js#L109), but this uses a React component, which I don’t have. How can I get access to this “triggerAction” from a “normal” plugin built like [GitHub - camunda/camunda-modeler-plugin-example: Plugin example for the Camunda Modeler. Use this as a starting point for creating your own plugins.](https://github.com/camunda/camunda-modeler-plugin-example)? Or is there another way to do this?

Thanks a lot  
Bernd

---

<div class="post-metadata">

**Author:** ![Niklas\_Kiefer](https://forum.bpmn.io/user_avatar/forum.bpmn.io/niklas_kiefer/32/3882_2.png) [@Niklas\_Kiefer](https://forum.bpmn.io/u/Niklas_Kiefer)\
**Post date:** [July 1, 2021, 2:12pm UTC](https://forum.bpmn.io/t/trigger-a-model-file-save-from-within-a-camunda-modeler-plugin/6423/2 "2021-07-01T14:12:49Z")

</div>

Since you’re creating a bpmn-js extension, there is no context for the current tab. One possibility to get it would be to wrap your extension inside a [client extension](https://github.com/camunda/camunda-modeler/blob/develop/resources/plugins/test-editor-events/client/TestEditorEvents.js#L57).

There you would have access to the `triggerAction`

```auto
constructor(props) {

  super(props);

  const {
    triggerAction
  } = props;

}

```

Inside your bpmn-js extension, you could then fire an event for your action.

```auto
function MyExtension(eventBus) {

  // fire this once you want to save the tab
  eventBus.fire('saveTab');

}

EditorEventsLogger.$inject = ['eventBus'];

```

And then listen for it in the React part

```auto
const {
  triggerAction,
  subscribe
} = props;

subscribe('bpmn.modeler.created', (event) => {

  modeler.on('saveTab', (event) => {    
    triggerAction('save');
  });

});

```

Something like that should be possible.

---

<div class="post-metadata">

**Author:** ![berndruecker](https://forum.bpmn.io/user_avatar/forum.bpmn.io/berndruecker/32/2938_2.png) [@berndruecker](https://forum.bpmn.io/u/berndruecker)\
**Post date:** [July 1, 2021, 2:41pm UTC](https://forum.bpmn.io/t/trigger-a-model-file-save-from-within-a-camunda-modeler-plugin/6423/3 "2021-07-01T14:41:32Z")

</div>

Hi Niklas.

A client extension is still part of a Modeler Plugin - right?

Do I understand it right, that [camunda-modeler/TestEditorEventsLogger.js at develop · camunda/camunda-modeler · GitHub](https://github.com/camunda/camunda-modeler/blob/develop/resources/plugins/test-editor-events/client/bpmn-modeler-extension/TestEditorEventsLogger.js) in your example is the “bpmn-js extension” which is then wrapped into the “client extension” in [camunda-modeler/index.js at develop · camunda/camunda-modeler · GitHub](https://github.com/camunda/camunda-modeler/blob/develop/resources/plugins/test-editor-events/client/index.js)?

Thanks a lot  
Bernd

---

<div class="post-metadata">

**Author:** ![Niklas\_Kiefer](https://forum.bpmn.io/user_avatar/forum.bpmn.io/niklas_kiefer/32/3882_2.png) [@Niklas\_Kiefer](https://forum.bpmn.io/u/Niklas_Kiefer)\
**Post date:** [July 2, 2021, 11:22am UTC](https://forum.bpmn.io/t/trigger-a-model-file-save-from-within-a-camunda-modeler-plugin/6423/4 "2021-07-02T11:22:08Z")

</div>

> Do I understand it right, that [camunda-modeler/TestEditorEventsLogger.js at develop · camunda/camunda-modeler · GitHub](https://github.com/camunda/camunda-modeler/blob/develop/resources/plugins/test-editor-events/client/bpmn-modeler-extension/TestEditorEventsLogger.js) in your example is the “bpmn-js extension” which is then wrapped into the “client extension” in [camunda-modeler/index.js at develop · camunda/camunda-modeler · GitHub](https://github.com/camunda/camunda-modeler/blob/develop/resources/plugins/test-editor-events/client/index.js)?

Exactly 👍 Note that (currently) in the example the [index file for the bpmn-js extension is missing](https://github.com/camunda/camunda-modeler/pull/2342).

Inside the [entry point](https://github.com/camunda/camunda-modeler/blob/develop/resources/plugins/test-editor-events/client/index.js#L15) of the plugin, the client extension would then get registered instead of the normal bpmn-js plugin.

---

<div class="post-metadata">

**Author:** ![berndruecker](https://forum.bpmn.io/user_avatar/forum.bpmn.io/berndruecker/32/2938_2.png) [@berndruecker](https://forum.bpmn.io/u/berndruecker)\
**Post date:** [July 19, 2021, 9:52am UTC](https://forum.bpmn.io/t/trigger-a-model-file-save-from-within-a-camunda-modeler-plugin/6423/5 "2021-07-19T09:52:11Z")

</div>

Hi Niklas.

Unfortunately, I seem to miss something. I deactivated the client extension - but you can see the code I tried here: [camunda-platform-to-cloud-migration/ConvertToCamundaCloudClientExtensionIndex.js at main · berndruecker/camunda-platform-to-cloud-migration · GitHub](https://github.com/berndruecker/camunda-platform-to-cloud-migration/blob/main/camunda-modeler-plugin-platform-to-cloud-converter/client/ConvertToCamundaCloudClientExtensionIndex.js) and here: [camunda-platform-to-cloud-migration/ConvertToCamundaCloudClientExtension.js at main · berndruecker/camunda-platform-to-cloud-migration · GitHub](https://github.com/berndruecker/camunda-platform-to-cloud-migration/blob/main/camunda-modeler-plugin-platform-to-cloud-converter/client/ConvertToCamundaCloudClientExtension.js)

I get an error:

```auto
ERROR in ./client/ConvertToCamundaCloudClientExtension.js
Module not found: Error: Can't resolve 'camunda-modeler-plugin-helpers/react' in 'C:\DEV\Camunda\camunda-platform-to-cloud-migration\camunda-modeler-plugin-platform-to-cloud-converter\client'
 @ ./client/ConvertToCamundaCloudClientExtension.js 6:0-69 20:66-79
 @ ./client/ConvertToCamundaCloudClientExtensionIndex.js

```

Any ideas?  
Does the code look OK from your perspective?

---

<div class="post-metadata">

**Author:** ![berndruecker](https://forum.bpmn.io/user_avatar/forum.bpmn.io/berndruecker/32/2938_2.png) [@berndruecker](https://forum.bpmn.io/u/berndruecker)\
**Post date:** [July 19, 2021, 10:28am UTC](https://forum.bpmn.io/t/trigger-a-model-file-save-from-within-a-camunda-modeler-plugin/6423/6 "2021-07-19T10:28:22Z")

</div>

We finally solved that problem now in a quick Zoom session:

1. I need to reference the right “client.js” created by Webpack in my index.js: [camunda-platform-to-cloud-migration/index.js at main · berndruecker/camunda-platform-to-cloud-migration · GitHub](https://github.com/berndruecker/camunda-platform-to-cloud-migration/blob/main/camunda-modeler-plugin-platform-to-cloud-converter/index.js#L6)
2. I no longer need to register the bpmn extension, but just return the module: [camunda-platform-to-cloud-migration/ConvertToCamundaCloudPluginIndex.js at main · berndruecker/camunda-platform-to-cloud-migration · GitHub](https://github.com/berndruecker/camunda-platform-to-cloud-migration/blob/main/camunda-modeler-plugin-platform-to-cloud-converter/client/ConvertToCamundaCloudPluginIndex.js) (as it is registered by the client extension itself: [camunda-platform-to-cloud-migration/ConvertToCamundaCloudClientExtension.js at main · berndruecker/camunda-platform-to-cloud-migration · GitHub](https://github.com/berndruecker/camunda-platform-to-cloud-migration/blob/main/camunda-modeler-plugin-platform-to-cloud-converter/client/ConvertToCamundaCloudClientExtension.js#L39))

Thanks Niklas!

---

<div class="post-metadata">

**Author:** ![SimonSteinruecken](https://forum.bpmn.io/user_avatar/forum.bpmn.io/simonsteinruecken/32/6531_2.png) [@SimonSteinruecken](https://forum.bpmn.io/u/SimonSteinruecken)\
**Post date:** [July 14, 2025, 2:17pm UTC](https://forum.bpmn.io/t/trigger-a-model-file-save-from-within-a-camunda-modeler-plugin/6423/7 "2025-07-14T14:17:32Z")

</div>

Closed on July 14, 2025, 2:17pm UTC

Closing old topics. If you have a similar question or need further assistance, please create a new topic and link to this one for context. Thank you!
