elsa-core icon indicating copy to clipboard operation
elsa-core copied to clipboard

[ENH] Add support to initialize the workflow context programmatically

Open b0rv3g4r4 opened this issue 1 year ago • 2 comments

In Elsa 2 we have the possibility to set a WorkflowContextId before dispatching a StartableWorkflow.

In Elsa 3 the workflows works as a module and we cant initialize the workflow context programmatically before we dispatch a workflow.

Example of use case:

I have a model Order (my custom context provider) that is the core of my workflow definition so my first activity start iterating all the products of this order to make things.

So it is very important to have the custom context available from the initial moment

b0rv3g4r4 avatar Nov 03 '23 11:11 b0rv3g4r4

Would it work for you if you can reuse the "input" parameter when executing or dispatching a workflow, and then from your workflow, you can read that input and use the SetWorkflowContextParameter activity to set the context value using a dynamic expression that reads from the input? Basically, this example?

sfmskywalker avatar Nov 19 '23 20:11 sfmskywalker

Right now to test I'm doing something like this, but from Elsa Studio I can't configure the context because of this:

https://github.com/elsa-workflows/elsa-studio/issues/75

Terminating the Activity, you could set the context at the start of the flow with the input as comments

It would still be nice to have a more direct way to pre-initiate the context

b0rv3g4r4 avatar Nov 20 '23 09:11 b0rv3g4r4