Question

Photo of Jeff Byrd

0

Workflow Lava Run SQL can't find current workflow

I have a workflow and I'm trying to run some SQL within a Lava Run action that utilizes the current Workflow Guid. The results are to get written to a text attribute. My problem is that when it executes, the query is never returning anything.

I did some troubleshooting and greatly simplified my query to prove the issue.

My simplified Lava Run action looks like this. I realize this does nothing but try to get the current workflow's Guid. My real query does a lot more.

{% sql %}
    select Guid
    from Workflow 
    where Guid='{{ Workflow.Guid }}'
{% endsql %}
results:{{results}}

I would expect the attribute to get set to

results:System.Dynamic.ExpandoObject

but it's always just

results:

If I execute the same query as a SQL action instead of a Lava Run action, the Guid is correctly set to the attribute.

Is there something limiting the Lava from properly running that query within a current workflow, or am I doing something wrong? It's most likely the latter :)

Thanks in advance for the help!

  • Photo of Jeff Byrd

    1

    I got it working, although I don't know all the details of why. The workflow is configured to be 'Automatically Persisted', but I'm guessing this doesn't actually persist it immediately. So, to solve it, I created an action to persist the workflow immediately. Then I run my Lava SQL Run and it works.

    Note: I originally stated that the SQL action worked correctly, but I must've been mistaken. I couldn't reproduce that working, which further validates my assumption about the workflow not persisting immediately.

  • Photo of Jeff Richmond

    0

    Are you sure the GUID exists when the Lava Run action happens? What happens if you add GUID: {{ Workflow.Guid }} to your Lava Run action?

  • Photo of Jeff Byrd

    0

    Thanks for the idea, Jeff. I added that to my action, and the GUID does indeed exist. But the results are still empty.

    Here is my action:

    RockWorkflow.jpg

    And here's the log from the output of my action.

    Set 'Test' attribute to 'GUID: 6c5211d3-9b5f-4eca-ba57-4c04acc8ed05 results:'.

    It's very strange that I'm not getting results.

  • Photo of Jeff Richmond

    0

    That does seem strange... unfortunately I'm not quite well-versed enough with Workflows to know what else to check at this point. I'll come back if I think of anything though.

    You could also try asking in the #workflows channel in Rock Chat if you haven't already.

  • Photo of Jeff Richmond

    0

    Nice! I thought it sounded like it wasn't persisted, but since you said the SQL action was working I ruled that out. Glad you figured it out, cause otherwise I was stumped!