Since today, my custom JavaScript library, which I import on app load, has stopped working in the “Workflow Editor”. When I try to test the workflow, I receive a “ReferenceError: doSomethingFunction is not defined.” Interestingly, the workflow functions correctly when I’m using the Real UI interaction in the Editor and in production. This issue did not exist before today.
Do you have any ideas on how I can resolve this?
Here is how I import the script (which worked previously):
let libScript = document.createElement(“script”);
libScript.src = “https://myhomepage.de/cdn/lib.js”;
document.head.appendChild(libScript);
that is only for loading the script correctly in the editor, then it depends on what your script is doing. if you are declaring a global function you also want to be sure to check if the script is fully loaded before trying to access it.
My script only declares some global functions. I can see that the script is loaded because I log it to the console when it’s there. And i’m using wwLib.getFrontDocument() now.
I also dobule checked if the script element is part of the editor page, and yes, i found it.
Hello, for anyone looking, I’ve wrote an article about implementing Firebase SDK (a JavaScript embed as well) into WeWeb, the pattern of implementation is very similar to what @dorilama suggested, but it’s described a little more in depth in the article.
I actually didn’t suggest any loading pattern here. I just noticed that usually if some code works in preview but not on workflow testing it’s because you need to use the right window and document objects.
When I need to load a library I usually don’t append script tags in the page