Get user actions dynamically
See original GitHub issueHi! I need to get user actions dynamically, I have already seen an example Sample12 and there I can change code like this and get actions:
using System;
using System.Linq;
using System.Threading.Tasks;
using Elsa.Activities.Console.Extensions;
using Elsa.Activities.UserTask.Activities;
using Elsa.Extensions;
using Elsa.Models;
using Elsa.Services;
using Elsa.Services.Extensions;
using Microsoft.Extensions.DependencyInjection;
namespace Sample12
{
/// <summary>
/// Demonstrates workflow correlation & user tasks.
/// </summary>
public static class Program
{
public static async Task Main(string[] args)
{
var services = BuildServices();
var registry = services.GetService<IWorkflowRegistry>();
var workflowDefinition = await registry.GetWorkflowDefinitionAsync<UserTaskWorkflow>();
var invoker = services.GetRequiredService<IWorkflowInvoker>();
// Start the workflow.
var correlationId = Guid.NewGuid().ToString("N");
var executionContext = await invoker.StartAsync(workflowDefinition, correlationId: correlationId);
do
{
var activity = (UserTask) executionContext.CurrentActivity;
// Workflow is now halted on the user task activity. Ask user for input:
Console.WriteLine($"What action will you take? Choose one of: {string.Join(", ", activity.Actions)}");
var userAction = Console.ReadLine();
// Resume the workflow with the received stimulus.
var triggeredExecutionContexts = await invoker.TriggerAsync(nameof(UserTask), new Variables { ["UserAction"] = new Variable(userAction)}, correlationId);
executionContext = triggeredExecutionContexts.First();
} while (executionContext.Workflow.IsExecuting());
}
private static IServiceProvider BuildServices()
{
return new ServiceCollection()
.AddElsa()
.AddConsoleActivities()
.AddWorkflow<UserTaskWorkflow>()
.BuildServiceProvider();
}
}
}
But in my application workflow is already started and if try to construct WorkflowExecutionContext like this
var workflowFactory = services.GetRequiredService<IWorkflowFactory>();
var workflow = workflowFactory.CreateWorkflow(workflowDefinition);
var executionContext = new WorkflowExecutionContext(workflow, services.GetRequiredService<IClock>(), services);
var userTask = (UserTask) executionContext.CurrentActivity;
My variable userTask is null.
Briefly, I need something like GetOpenUserActions in WorkflowCore.
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
c# - Get event from dynamically added button in UserControl
I want the event to be raised in the Form in which i am adding the UserControl . Please if anyone could suggest...
Read more >Use Dynamic Actions to Show the Right Actions to the User at ...
Dynamically show actions to your users using action visibility in Lightning Experience. Important things to note about dynamic actions: Dynamic ...
Read more >Dynamically creating JavaScript elements with event ...
This tutorial explores the concepts of events, event listeners, and dynamically creating new JavaScript elements by using document.
Read more >Dynamically generated Django admin actions
Django's admin actions are a useful way of applying a process to a set of records. Django by default has only “delete selected...
Read more >Salesforce Dynamic Actions: Overview & Deep Dive Tutorial
Dynamic Actions will enable you to create uncluttered, intuitive and responsive pages that display only the actions your users need to see ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

For Anyone who ask about this , after reading the great documentation
UserTaskis just aclassthe inherits fromactivity.it has one more virtual method which called
OnCanExecutewhich retruns a bool if true it will go as a normal activity if not it will just terminate the execution .its also had
ActivityInputcalled action which takes the actions as string[] .https://elsa-workflows.github.io/elsa-core/docs/next/guides/guides-blocking-activities
this tutorial is more than enough for the user task example.
finaly, thanks for this awesome library
I’m afraid not as of yet. Shifting priorities and all that.