elsa-workflows / elsa-core

A .NET workflows library
https://v3.elsaworkflows.io/
MIT License
5.88k stars 1.07k forks source link

Elsa.WriteLine expression and memory reference #5302

Open mremadevi opened 2 weeks ago

mremadevi commented 2 weeks ago

Discussed in https://github.com/elsa-workflows/elsa-core/discussions/5301

This seems to be a bug , I am using Elsa 3.1.3 libraries and Elsa Studio 3.2 . Attached JSON file when loaded through code and run memory reference is not handled correctly. issue-test.json

Originally posted by **mremadevi** April 29, 2024 This is in reference to discussion #5300 Understand that memory reference is an internal mechanism used Elsa to track activity inputs and outputs and defining workflow through designer handles the reference internally . If the workflow is defined thorough visual designer and saved as JSON file . Application loads the JSON file and executes the workflow through code , how is references handled ? In example below WriteLine uses output of previous activity set in variable as input using expressions . When JSON is exported , there is no memory reference for input 'text'. It only has expression. This will fail when JSON workflow file is loaded and executed from code with memory reference doesn`t exist error. Manually setting a unique memory reference id is also not working . What is the right way to use previous activity output when loading workflows from JSON file and running workflow from code. { "text": { "typeName": "String", "expression": { "type": "JavaScript", "value": "Nice to meet you, ${getName()}!" } }, "id": "WriteLine2", "type": "Elsa.WriteLine" }
glime-ai[bot] commented 2 weeks ago

Based on the context provided, it seems that you are encountering an issue with memory references when loading workflows from a JSON file and executing them through code. The memory reference is indeed an internal mechanism used by Elsa to track activity inputs and outputs. When you define a workflow through the visual designer and export it to a JSON file, the memory references should be handled automatically by Elsa.

However, if you are experiencing issues with memory references not being recognized when loading the JSON workflow file and executing it from code, it could be due to a mismatch between the version of Elsa Studio used to create the workflow and the version of the Elsa libraries used to execute the workflow. It's important to ensure that the versions are compatible.

To address the issue, you should:

  1. Ensure that the versions of Elsa Studio and the Elsa libraries you are using are compatible.
  2. Verify that the JSON file is correctly formatted and contains all necessary information, including memory references.
  3. If you are manually editing the JSON file, ensure that the memory references are unique and correctly mapped to the corresponding activities.

If the problem persists, it may be a bug, and you should consider reporting it to the Elsa GitHub repository or seeking further assistance from the Elsa community.

For more detailed guidance on how to use previous activity outputs when loading workflows from JSON files, you can refer to the Elsa documentation or seek help from the community forums or GitHub discussions.

This comment was generated by Glime.