Shopify Flow (run code)

I just created a basic workflow and tried to run the default Run Code that spits out the Hello World from shop name, the trigger being an order created, but even a simple code as such yields a blank result. Is there something am missing or not doing right? This is running on my dev store with plus.


Hi there!

You will want to use console.log() if you want a simple output from a Run code step.

console.logs are what gets output in the message array.
Naming a variable in the SDL output as message confuses the best of us.

Flow I’m using for reference:

The purpose of the SDL output is so it can be used in a following condition or action step like this:

With your Flow, you can also use the ‘Log output’ action step to output the message variable like this instead:

Hope that helps!

Feature suggestion:

Do not allow message as a key in Output if it will be shadowed by the console.log mechanism.

1 Like

There was nothing wrong with the code, its just the workflow isn’t returning the variable, I ran previous flows and they are no issues, here is my sample code which I find odd as it only returns a simple SDL variable which is hardcoded.

Do individual workflows have their own web-worker or is there a caching that expires?

This is running on a dev-store so I am just finding it a bit odd it isn’t working as expected.

I found that the app only returns the output for variables that are utilized in a later step.

Try adding a simple Log output step to your workflow where you reference your variables e.g. {{ runCode.testVariable }}.
You will see the expected output for the Run code step then.

This is either an undocumented optimization strategy or unexpected behavior. Bear with me while I confirm this.

1 Like

Confirmed that is an optimization of the Flow app.
I will work on getting this documented :slight_smile:

Ok, so this is a optimization in that it removes keys that are not used in subsequent steps, and not that a key called “message” is filtered out? Just want to clarify my earlier post.

Yeah that’s right.
I misunderstood the question initially and thought they were expecting it where console.logs get output. For reference:

Thank you for the clarification. If you feel like my comment is distracting or misleading, I understand if you’d like to moderate/delete it.