Can't test workflow through workflow editor (need to launch through preview mode in editor)

So I have a file uploader to which a workflow is handling the upload through a form-data POST to Xano in a Javascript code block.

I have some issues testing this workflow: when I trigger the workflow through the preview mode of the editor, it works as expected. However, when I trigger the workflow in the workflow editor, it fails at the Javascript block.

Here’s the error:

name: "TypeError"
stack: "TypeError: Cannot read properties of null (reading 'files') at eval (eval at executeCode (, :9:40) at eval (eval at executeCode (, :59:3) at executeCode ( at _t ( at It ( at It ( at async It ( at async It ( at async It ( at async It ( at async It ( at async Ct ("
message: "Cannot read properties of null (reading 'files')"

Basically, it looks like the Javascript code block doesn’t have access to the uploader files when in the workflow editor context.

Here’s how those files are selected in code:

var imagefile = document.querySelector('[name="uploader"]');

Is there a better way to select files so that it works in the workflow editor? Or is this a limitation that we can’t work around.


you should replace document by wwLib.getFrontDocument()

The editor is running the website inside the iframe, and depding on where you execute your code, the document variable may refer to something different.
wwLib.getFrontDocument() always return the correct document

1 Like

Awesome thanks so much for the quick and detailed reply Aurelie!