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

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.

Hi, you can call a workflow using

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 ?

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?

Yes, which backend/auth plugin do you use ?

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.

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

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.

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.

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 :slight_smile:

1 Like

It’s the same workflow as last night.

These are the global workflows right?

I am getting this output in the console:

This is weird, please submit a ticket on support.weweb.io so we can give it a look :slight_smile:

1 Like

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

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

1 Like

We’ll do when I write it up.

1 Like