# Run Component Workflow with Javascript

**URL:** <https://community.weweb.io/t/run-component-workflow-with-javascript/15463>\
**Category:** How do I?\
**Created:** [January 19, 2025, 1:50pm UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463 "2025-01-19T13:50:59Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![carrano\_dot\_dev](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/carrano_dot_dev/32/10547_2.png) [@carrano\_dot\_dev](https://community.weweb.io/u/carrano_dot_dev)\
**Post date:** [January 19, 2025, 1:50pm UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/1 "2025-01-19T13:50:59Z")

</div>

Is it possible to trigger a component’s workflow with javascript (without hacky workarounds)?

I’ve try wwLib.wwWorkflow.executeGlobal and wwLib.executeWorkflow with the workflow’s ID but I get an error saying the workflow was not found.

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [January 19, 2025, 9:06pm UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/2 "2025-01-19T21:06:23Z")

</div>

You need to use the special component workflow action, I can’t seem to find it right now. A workaround would be to:

1. Create a global workflow that uses the “Execute component workflow” action
2. Call that via the `wwLib.executeWorkflow` with the Global Workflow’s ID

While it’s not the most ideal, it’s the easiest I think. This also allows you to edit further your Workflow in no-code.

---

<div class="post-metadata">

**Author:** ![carrano\_dot\_dev](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/carrano_dot_dev/32/10547_2.png) [@carrano\_dot\_dev](https://community.weweb.io/u/carrano_dot_dev)\
**Post date:** [January 19, 2025, 10:44pm UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/3 "2025-01-19T22:44:29Z")

</div>

Yeah that could work for some use cases.

What I want to do is use a component workflow inside the custom javascript of another workflow in the component, and also be able to call the workflow from outside the component.

I have a workaround right now but it’s not the cleanest.

---

<div class="post-metadata">

**Author:** ![heypierrot](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/heypierrot/32/11139_2.png) [@heypierrot](https://community.weweb.io/u/heypierrot)\
**Post date:** [March 5, 2025, 2:46pm UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/4 "2025-03-05T14:46:13Z")

</div>

Hi, actually the ones you tried work for global workflows but not for the components workflows.

The feature for component workflows has been implemented last year in march ([🧰 Extended component features, UI improvements, and bug fixes](https://www.weweb.io/changelog/2024-03-20)) 🙂

You simply needs to call the following function in Javascript:

```auto
context.component.methods.executeWorkflow(componentWorkflowId)

```

---

<div class="post-metadata">

**Author:** ![carrano\_dot\_dev](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/carrano_dot_dev/32/10547_2.png) [@carrano\_dot\_dev](https://community.weweb.io/u/carrano_dot_dev)\
**Post date:** [March 5, 2025, 2:52pm UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/5 "2025-03-05T14:52:39Z")

</div>

> [@heypierrot](#):
>
> `context.component.methods.executeWorkflow(componentWorkflowId)`

Good to know! However, I also want to be able to execute them from outside the component when marked as ‘Allow execution from outside’

---

<div class="post-metadata">

**Author:** ![GeraldoNeves](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/geraldoneves/32/4695_2.png) [@GeraldoNeves](https://community.weweb.io/u/GeraldoNeves)\
**Post date:** [March 17, 2025, 12:53pm UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/6 "2025-03-17T12:53:36Z")

</div>

But what we have is the name of the Workflows component. How can we find out the componentWorkflowId ??

---

<div class="post-metadata">

**Author:** ![carrano\_dot\_dev](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/carrano_dot_dev/32/10547_2.png) [@carrano\_dot\_dev](https://community.weweb.io/u/carrano_dot_dev)\
**Post date:** [March 18, 2025, 11:18am UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/7 "2025-03-18T11:18:00Z")

</div>

More \> Development \> Show dev information

Then you’ll see a ‘Copy ID’ button inside the workflow

---

<div class="post-metadata">

**Author:** ![kdjamo](https://avatars.discourse-cdn.com/v4/letter/k/45deac/32.png) [@kdjamo](https://community.weweb.io/u/kdjamo)\
**Post date:** [May 31, 2025, 12:40am UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/8 "2025-05-31T00:40:50Z")

</div>

Hello, I am trying to execute this workflow  
**context.component.methods.executeWorkflow(‘ID of Workflow here’);**

This is running from a workflow connected with a button and it triggers the following error:  
**“Cannot read properties of undefined (reading ‘methods’)at window.cloudflareEventHandler”.**

I also tried to run this in a HTML element within a component but had the same error.  
Is there more information wher we can run this one from? Or other best practice? Thanking you

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [May 31, 2025, 6:53am UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/9 "2025-05-31T06:53:25Z")

</div>

This only works when invoking from within the component I think. If you wanna invoke it from the outside, you need to setup a Global workflow and invoke it via a different method.

---

<div class="post-metadata">

**Author:** ![axel1](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/axel1/32/16440_2.png) [@axel1](https://community.weweb.io/u/axel1)\
**Post date:** [April 17, 2026, 3:13pm UTC](https://community.weweb.io/t/run-component-workflow-with-javascript/15463/10 "2026-04-17T15:13:58Z")

</div>

> [@carrano\_dot\_dev](#):
>
> component

Can we also pass workflow parameter when calling this function ?
