How to access variables set on the workflow from the activity? #5726
Replies: 1 comment
-
Yes, you can load and use variables within an activity when creating a workflow programmatically in Elsa. To access a workflow variable from within an activity, you can use the protected override async ValueTask<IActivityExecutionResult> OnExecuteAsync(ActivityExecutionContext context)
{
// Retrieve the variable value from the workflow instance storage.
var myVariableValue = context.GetVariable<string>("MyVariable");
// Use the variable value as needed in your activity logic.
// ...
return Done();
} In this example, Please note that for this to work, the variable "MyVariable" must have been previously created and stored in the workflow instance. This can be done programmatically when building the workflow or through the designer interface. For more information on variables and their usage in Elsa, you can refer to the documentation on variables at the provided link. If you need further assistance or if there's anything specific you're trying to achieve with the variable, please let me know! This comment was generated by Glime. |
Beta Was this translation helpful? Give feedback.
-
I am creating a workflow programatically. While creating there few variables set on them. I need one of those variable to load the list data in the activity. I checked the available properties on the activity and couldn't find anything. Also previous questions are for cascading dropdowns, which is not i want. Is there a way to do it?
Beta Was this translation helpful? Give feedback.
All reactions