Calling a function within a workflow, from an app

Hi there,

I’ve run into what seems to be a bug when working with Workflows.

When I call a workflow that returns a simple response (e.g. a string or object via a return block), I can easily access the response data in the calling resource (e.g. workflow.data). That works as expected.

However, when the same workflow includes a function block that internally calls another workflow (nested workflow), I can no longer access the response data. The .data field remains undefined or empty, even though the nested workflow executes successfully and has a response of its own.

Is this expected behavior?
If not, is there a workaround to access the final response from workflows that include nested function blocks?

Thanks! Would love to know if others are experiencing the same.

So startTrigger -> response1 works. startTrigger -> function (Workflow) -> response1 does not.

Even though I am calling the same starting point (startTrigger) from within the app

Can you test the nesting by connecting the nested workflow's startTrigger directly to a Response and see if it returns what it is given?

I was running into a weird workflow error yesterday when a loop block that is supposed to call a workflow, would fail on the first iteration with

Error processing iteration 0: {} or similiar

Well yes, function (Workflow) -> startTrigger -> response1 does work, but startTrigger -> function (Workflow) -> startTrigger -> response1 does not.

when you say function (Workflow) do you mean a Multi-step function? The kind that opens the nested workflow editor? or a whole separate workflow?

Multi-step function with a nested workflow editor yes!

A super quick test from me produces this...

Are you accessing and returning from the function like this?

and then when I run the whole thing....

I am calling a workflow from within an app. This workflow has a multi-step flow in it. Have you tried that?

When executing the chain the devug console states that the workflow has 'ran successfully'. When printing {{ improveWorflow.data }} in a text component it renders [object Object].

Both
{{ improveProduct.data.status }}
{{ improveProduct.data.hello }}
{{ improveProduct.data.productUrl }}
{{ improveProduct.data.adArchiveId }}

Don't render anything. Am I missing something?

[object Object] is good!! that means you are actually getting data back.

try {{ JSON.stringify(improveWorflow.data) }} and you should see what it is returning :slight_smile:

It could be a double nesting or array nesting? I have ran into that, like maybe it needs to be...

{{ improveProduct.data.data.status }} or {{ improveProduct.data[0].status }}

1 Like

Thanks, tried practically everything, unfortunately no results :rofl:

Hi @devopser,

That is good that you are getting [object Object] as that has data inside of it, we just need to look into that as @khill-fbmc suggested to see if that data is what you expected.

In the screenshot above, can you mouse over the results of JSON.stringify() where it is green to see what the returned value of that method is giving us? My hope is that one of them is returning exactly what you are looking for :sweat_smile:

In your second screenshot, you are displaying that runFunction1 has a return block which is causing that function block to return the object that your second arrow is pointing at.

Is that data payload with status, hello, productURL, adArchiveId not what you are expecting to get back?

If you click 'edit function' on runFunction1 can you take a screen shot of the return block? I am imagining that you are passing in productURL, adArchiveId params, doing some logic and then want other data back, are you missing the other data that is defined in the return block?

I am curious how this


is returning anything when it appears to stand alone with no connections.

EDIT: I think I know!

I have to do this to get the data out of my workflow functions. Are you awaiting?
image

My function is only single-step, but maybe??

How do I use await in an app? It seems like response block deeper than 1 workflow aren't returned to the app.

I think for this one you just need to use another response block outside of the nested flow/function: