elsa-workflows / elsa-workflows/elsa-core
In loopback the Fork works correctly but Join didn't start second time
- Dominant language
- C#
- Stars
- 7.9k
- Forks
- 1.5k
- Avg merge
- 15h 22m
- Merged PRs (30d)
- 114
Description
I am implementing the loopback scenario, after Rejected event trigger, the Decision activity will loopback the flow to Submitted Event, but when I trigger the Approved event now, the workflow will be suspended and Rejected Event activity is not canceled and flow never reached to Join
Now, If I trigger Approved first time everything will work fine.
I used INotificationHandler where I am setting the Event name to Workflow level variable (UserAction), which I check in Decision Activity. I also che
ck that if the notification is Approved activity and IsCompleted then Canceled the Rejected activity manually but still the Join didn't started
I am also attaching the workflow json
[doc-flow-3.json](https://github.com/user-attachments/files/23157343/doc-flow-3.json)
### WorkflowStatusListner.cs
`
public class WorkflowStatusListener : INotificationHandler
{
public Task HandleAsync(ActivityExecuted notification, CancellationToken cancellationToken)
{
if (notification.ActivityExecutionContext.Activity is Event && notification.ActivityExecutionContext.IsCompleted)
{
notification.ActivityExecutionContext.WorkflowExecutionContext.Variables.First(v => v.Name == "UserAction")
.Set(notification.ActivityExecutionContext, notification.ActivityExecutionContext.Activity.Name);
if (notification.ActivityExecutionContext.Activity.Name == "Approved")
{
var rejected = notification.ActivityExecutionContext.WorkflowExecutionContext.ActivityExecutionContexts.First(a => a.Activity.Name == "Rejected");
rejected.CancelActivityAsync();
}
notification.ActivityExecutionContext.AddExecutionLogEntry("Customer Log Entry Activity Executed", message: $"Activity {notification.ActivityExecutionContext.Activity.GetDisplayText()} executed.", payload: new
{
ActivityId = notification.ActivityExecutionContext.Activity.Id,
ActivityType = notification.ActivityExecutionContext.Activity.GetType().Name,
WorkflowInstanceId = notification.ActivityExecutionContext.WorkflowExecutionContext.Id,
Timestamp = DateTime.UtcNow
});
}
return Task.CompletedTask.WaitAsync(new TimeSpan(0));
}
}
`
Contributor guide
Assessment
This issue has not been assessed yet.