# Custom JS Trying to executeWorkflow with workflow id but getting workflow not found

**URL:** <https://community.weweb.io/t/custom-js-trying-to-executeworkflow-with-workflow-id-but-getting-workflow-not-found/5982>\
**Category:** Developer corner\
**Created:** [December 16, 2023, 5:38pm UTC](https://community.weweb.io/t/custom-js-trying-to-executeworkflow-with-workflow-id-but-getting-workflow-not-found/5982 "2023-12-16T17:38:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![juljuc](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@juljuc](https://community.weweb.io/u/juljuc)\
**Post date:** [December 16, 2023, 5:38pm UTC](https://community.weweb.io/t/custom-js-trying-to-executeworkflow-with-workflow-id-but-getting-workflow-not-found/5982/1 "2023-12-16T17:38:41Z")

</div>

I am trying to execute a workflow that calls itself to refresh the data on my page. I created a global workflow (in the Action menu) that checks my data, and then uses a setTimeout in a custom JS to call itself again with its workflow ID. It works once on page load, but then i get an error in the console saying workflow not found. When i try executing the JS command in the console, it finds the workflow and then keeps looping as expected.  
Why doesn’t it find the workflow in the first execution context. Here’s the JS in the custom JS action i have:

````auto
setTimeout(() => { window.wwLib.executeWorkflow("9657722a-14e3-40a2-bad9-286a107716e3") }, 5000);```
````

---

<div class="post-metadata">

**Author:** ![aurelie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/aurelie/32/13249_2.png) [@aurelie](https://community.weweb.io/u/aurelie)\
**Post date:** [December 18, 2023, 1:32pm UTC](https://community.weweb.io/t/custom-js-trying-to-executeworkflow-with-workflow-id-but-getting-workflow-not-found/5982/2 "2023-12-18T13:32:47Z")

</div>

Hi,  
when are you starting the first call of your workflow? Best practise is to do it on a OnPageLoad workflow 🙂

---

<div class="post-metadata">

**Author:** ![juljuc](https://avatars.discourse-cdn.com/v4/letter/j/8baadc/32.png) [@juljuc](https://community.weweb.io/u/juljuc)\
**Post date:** [December 18, 2023, 2:10pm UTC](https://community.weweb.io/t/custom-js-trying-to-executeworkflow-with-workflow-id-but-getting-workflow-not-found/5982/3 "2023-12-18T14:10:08Z")

</div>

It’s weird, I have it in the Actions tab, it says “On Execution” in the trigger, and it practically is executed at page load. This morning, there’s no more error about workflow not found.

---

<div class="post-metadata">

**Author:** ![aurelie](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/aurelie/32/13249_2.png) [@aurelie](https://community.weweb.io/u/aurelie)\
**Post date:** [December 18, 2023, 2:53pm UTC](https://community.weweb.io/t/custom-js-trying-to-executeworkflow-with-workflow-id-but-getting-workflow-not-found/5982/4 "2023-12-18T14:53:59Z")

</div>

On execution means that it needs to be called somewhere. So you probably have an other one calling it somewhere.  
You can use the find workflow button to find where

![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/d/d7b794acb1bf37b4d05ebb60d308e471c39269f2.png)
