# Is there a way to trigger a workflow when a variable changes?

**URL:** <https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662>\
**Category:** Ask us anything\
**Tags:** workflows\
**Created:** [July 24, 2023, 4:24pm UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662 "2023-07-24T16:24:53Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![raae](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@raae](https://community.weweb.io/u/raae)\
**Post date:** [July 24, 2023, 4:24pm UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/1 "2023-07-24T16:24:53Z")

</div>

I am setting a variable using Javascript and would like it to trigger a workflow? Triggering a workflow from Javascript could also work in my case.

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [July 24, 2023, 4:48pm UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/2 "2023-07-24T16:48:23Z")

</div>

Hi, you can call a workflow using

```auto
wwLib.executeWorkflow(workflowId, parameters)

```

but if you can, it’s better to add an action executeWorkflow after your custom js action. Use this code only if your logic can’t be splitted into two distinct part where the first one is the variable update and the second one the workflow execution.

But why did you need a javascript code to update a variable ? You can’t use the update variable action ?

---

<div class="post-metadata">

**Author:** ![raae](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@raae](https://community.weweb.io/u/raae)\
**Post date:** [July 24, 2023, 9:54pm UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/3 "2023-07-24T21:54:40Z")

</div>

I am testing out a flow where i use Outseta’s embeds, not WeWeb forms, but I would like to trigger the store token + fetch profile workflow. Does that make sense?

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [July 25, 2023, 7:02am UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/4 "2023-07-25T07:02:31Z")

</div>

Yes, which backend/auth plugin do you use ?

---

<div class="post-metadata">

**Author:** ![raae](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@raae](https://community.weweb.io/u/raae)\
**Post date:** [July 25, 2023, 9:39am UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/5 "2023-07-25T09:39:38Z")

</div>

That would be Outseta Auth; I am their DevAdvocate. I see there is an Outseta Auth Plugin on the roadmap under consideration and would love to help make that happen.

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [July 25, 2023, 11:23am UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/6 "2023-07-25T11:23:52Z")

</div>

Did you try the Token Based auth plugin ? What’s your auth flow ?

---

<div class="post-metadata">

**Author:** ![raae](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@raae](https://community.weweb.io/u/raae)\
**Post date:** [July 25, 2023, 1:50pm UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/7 "2023-07-25T13:50:26Z")

</div>

Yes, but we have a custom registration widget that contains logic I don’t want to recreate in WeWeb. So I am listening for our accessToken.set event and then triggering the workflow.

---

<div class="post-metadata">

**Author:** ![raae](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@raae](https://community.weweb.io/u/raae)\
**Post date:** [July 25, 2023, 2:09pm UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/8 "2023-07-25T14:09:13Z")

</div>

Workflows worked really well last night, but now I am getting “Error: Workflow not found.” I have tried to trigger straight from the console with id’s copied from the workflow.

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [July 25, 2023, 2:18pm UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/9 "2023-07-25T14:18:16Z")

</div>

You have to use the id of a global workflow, you can find them by doing in your console  
`wwLib.$store.getters['data/getGlobalWorkflows'];`

Warning : Do not use this snippet inside your project code, it could break in the future, use it only to get the information you need in the console 🙂

---

<div class="post-metadata">

**Author:** ![raae](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@raae](https://community.weweb.io/u/raae)\
**Post date:** [July 25, 2023, 2:27pm UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/10 "2023-07-25T14:27:05Z")

</div>

It’s the same workflow as last night.

These are the global workflows right?

 ![CleanShot 2023-07-25 at 16.24.47@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/2/23abf370ed507e4948b1e8fd7fa8d10b41805dfe.png)

I am getting this output in the console:

 ![CleanShot 2023-07-25 at 16.25.47@2x](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/8/858e3648647f10d1f2b1a3a4e0851e9b5b25873e.png)

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [July 26, 2023, 10:06am UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/11 "2023-07-26T10:06:43Z")

</div>

This is weird, please submit a ticket on [support.weweb.io](http://support.weweb.io) so we can give it a look 🙂

---

<div class="post-metadata">

**Author:** ![raae](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@raae](https://community.weweb.io/u/raae)\
**Post date:** [July 26, 2023, 11:39am UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/12 "2023-07-26T11:39:20Z")

</div>

Will do that, but came up with a better alternative solution so no rush. Thank you for all the help!

---

<div class="post-metadata">

**Author:** ![Alexis](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/alexis/32/13248_2.png) [@Alexis](https://community.weweb.io/u/Alexis)\
**Post date:** [July 26, 2023, 12:38pm UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/13 "2023-07-26T12:38:44Z")

</div>

Would you mind share with me your solution ? It may benefit to other! 🙂

---

<div class="post-metadata">

**Author:** ![raae](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@raae](https://community.weweb.io/u/raae)\
**Post date:** [July 30, 2023, 5:16am UTC](https://community.weweb.io/t/is-there-a-way-to-trigger-a-workflow-when-a-variable-changes/3662/14 "2023-07-30T05:16:41Z")

</div>

We’ll do when I write it up.
