elsa-workflows / elsa-workflows/elsa-core
How to make the activity execute automatically after the process is restored?
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
Hello, I have a scenario like this: an employee submits information, and after the department approves it, it is transferred to the manager approval node. However, at the manager approval node, a withdrawal operation may be performed, withdrawing to the previous approval node, which is the department node. At this time, the department supervisor needs to re-approve, but why doesn’t it automatically transfer to the manager approval node after re-approval? Below is my related code, I hope to get your reply, thank you!
public class Department : CodeActivity
{
protected override async ValueTask ExecuteAsync(ActivityExecutionContext context)
{
await context.CompleteActivityAsync();
//The Manager node can be executed automatically the first time it is run
//When it is run for the second time, the next node to be executed should also be Manager
}
}
public class Manager : Activity
{
protected override void Execute(ActivityExecutionContext context)
{
var list = new List() {"Tag1","Tag2","Tag3" };
context.CreateBookmarks(list, ResumeAsync, false);
}
private async ValueTask ResumeAsync(ActivityExecutionContext context)
{
//7c6e64b08741151a is Department
var aa = context.WorkflowExecutionContext.FindActivityById("7c6e64b08741151a");
context.WorkflowExecutionContext.ScheduleActivity(aa);
}
}
public async Task TestWorkflow(string workflowInstanceId)
{
var instanceFilter = new WorkflowInstanceFilter()
{
Id = workflowInstanceId
};
var workflowInstance = await _workflowInstanceStore.FindAsync(instanceFilter);
var workflowState = workflowInstance.WorkflowState;
if (workflowState.Bookmarks.Count > 0)
{
var bookmark = workflowState.Bookmarks.FirstOrDefault();
var options = new Elsa.Workflows.Options.RunWorkflowOptions { BookmarkId = bookmark.Id };
var message = new Elsa.Workflows.Runtime.Models.NewWorkflowInboxMessage
{
BookmarkPayload = bookmark.Payload,
ActivityTypeName = ActivityTypeNameHelper.GenerateTypeName(),
WorkflowInstanceId = workflowInstanceId
};
}
}

After the department node is executed, it should trigger the manager node, right? This is also what I hope to happen.
Contributor guide
Assessment
This issue has not been assessed yet.