Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] How activity retrieve variable within published workflow #5541

Open
yusianglin11010 opened this issue Jun 5, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@yusianglin11010
Copy link

Description

After a workflow published, I try to retrieve its variable in the activity, but cannot access it by ExpressionExecutionContext. The Expression which created by JavaScriptExpression works fine.

Steps to Reproduce

public class TriggerWorkflow : WorkflowBase
{
    protected override void Build(IWorkflowBuilder builder)
    {
        var timer = new Timer(TimeSpan.FromSeconds(3))
        {
            CanStartWorkflow = true
        };
        builder.Root = new Sequence() 
        { 
            Activities = 
            { 
                timer,
                new WriteLine(JavaScriptExpression.Create(JsExpressionConstructor("getVariable('text')"))),
                new WriteLine(context => context.GetVariable<string>("text"))
            }, 
        }; 
    }
}

Expected Behavior

Expect that the both WriteLine activity would output the same string

Actual Behavior

The second WriteLine get nothing from context.GetVariable<string>("text")

Environment

  • Elsa Package Version: 3.1.2
@yusianglin11010 yusianglin11010 added the bug Something isn't working label Jun 5, 2024
Copy link

glime-ai bot commented Jun 5, 2024

Based on the context provided, it seems that you are trying to access a workflow variable named text in a WriteLine activity using two different methods: a JavaScript expression and a C# lambda expression. The JavaScript expression is working fine, but the C# lambda expression is not retrieving the variable as expected.

To troubleshoot this issue, please ensure that the variable text is properly defined and registered in the workflow's variables collection. If the variable is not defined, the context.GetVariable<string>("text") call will not be able to retrieve it.

If the variable is indeed defined and you are still facing issues, it could be related to the scope of the variable or the timing of when the variable is being set versus when it is being accessed. Variables in Elsa workflows have a specific scope, and if the WriteLine activity is executed before the variable is set, it will not be able to retrieve the value.

Additionally, ensure that the version of Elsa you are using does not have a known issue related to variable access. You can check the Elsa GitHub issues page for any reported bugs that match your scenario.

If you continue to experience issues, consider reaching out to the Elsa community or support channels with a detailed description of your workflow and the steps you have taken to define and access the variable.

This comment was generated by Glime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant