Fix dangling activity exception when resuming flowcharts with multiple triggers #7215
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
Flowcharts with multiple triggers fail when resuming:
"Activity X is not reachable from the flowchart graph. Unable to schedule its outbound activities"This occurs when:
canStartWorkflow: false)TriggerActivityIdGetFlowGraph()recreates FlowGraph with trigger B as rootSolution
Modified
MaybeScheduleOutboundActivitiesAsyncto distinguish between:Activities with outbound connections were legitimately scheduled and should complete regardless of FlowGraph root changes during resumption.
Original prompt
This section details on the original issue you should resolve
<issue_title>Unable to schedule outbound activity</issue_title>
<issue_description>Hello,
I have created minimal project for clean slate operation
PFA zip of the project along with reproducing steps
Step1 : Save Definition with below JSON
{"model":{"definitionId":"Hiten V Test","name":"Hiten V Test","description":null,"inputs":[],"outputs":[],"option":[],"variables":[{"id":"5b77a66d-64f7-4f3a-ad1d-81316703dedb","name":"RootTrigger","typeName":"Object","value":null,"storageDriverTypeName":"Elsa.Workflows.WorkflowInstanceStorageDriver, Elsa.Workflows.Core"},{"id":"70552eab-2cbf-43bf-9a23-52ab26b9274c","name":"CreateChildTask1","typeName":"Object","value":null,"storageDriverTypeName":"Elsa.Workflows.WorkflowInstanceStorageDriver, Elsa.Workflows.Core"},{"id":"48241bec-839b-4d23-8483-fc9e856df3c5","name":"CreateChildTask2","typeName":"Object","value":null,"storageDriverTypeName":"Elsa.Workflows.WorkflowInstanceStorageDriver, Elsa.Workflows.Core"},{"id":"6e29a489-1804-43fe-b51b-6de0dddbb68a","name":"SendEmail3","typeName":"Object","value":null,"storageDriverTypeName":"Elsa.Workflows.WorkflowInstanceStorageDriver, Elsa.Workflows.Core"}],"root":{"name":"Flowchart1","type":"Elsa.Flowchart","activities":[{"name":"RecordCreated","type":"ElsaCleanSlate.Triggers.RecordCreated","customProperties":{"canStartWorkflow":true,"runAsynchronously":false},"statusId":{"typeName":"Int16","expression":{"type":"Literal","value":0}},"fieldId":{"typeName":"String","expression":{"type":"Literal","value":""}},"entityTypeId":{"typeName":"Int16","expression":{"type":"Literal","value":5}},"taskTypeId":{"typeName":"Int32","expression":{"type":"Literal","value":0}},"entityId":{"typeName":"Int32"},"id":"a2541a4d-1f06-4cff-a6f6-2ffcdea29e87","isImmediateTrigger":{"typeName":"Boolean","expression":{"type":"Literal","value":true}},"result":{"typeName":"Object","memoryReference":{"id":"5b77a66d-64f7-4f3a-ad1d-81316703dedb"}}},{"name":"CreateChildTask1","type":"ElsaCleanSlate.Activities.CreateChildTask","result":{"typeName":"Object","memoryReference":{"id":"70552eab-2cbf-43bf-9a23-52ab26b9274c"}},"inputJson":{"typeName":"String","expression":{"type":"JavaScript","value":"JSON.stringify({Metadata:{TaskTitle:"AP02 Task from Workflow"},EntityId:0,EntityTypeId:5,ParentTaskId:getVariable('RootTrigger').EntityId,ChildTaskTypeId:75})"}},"conditionJson":{"typeName":"String"},"id":"70552eab-2cbf-43bf-9a23-52ab26b9274c"},{"name":"RecordUpdated","type":"ElsaCleanSlate.Triggers.RecordUpdated","customProperties":{"canStartWorkflow":true,"runAsynchronously":false},"statusId":{"typeName":"Int16","expression":{"type":"Literal","value":0}},"fieldId":{"typeName":"String","expression":{"type":"Literal","value":""}},"entityTypeId":{"typeName":"Int16","expression":{"type":"Literal","value":5}},"taskTypeId":{"typeName":"Int32","expression":{"type":"Literal","value":0}},"entityId":{"typeName":"Int32"},"id":"8f13496a-3372-4c01-8f38-7fae5f346899","isImmediateTrigger":{"typeName":"Boolean","expression":{"type":"Literal","value":true}},"result":{"typeName":"Object","memoryReference":{"id":"5b77a66d-64f7-4f3a-ad1d-81316703dedb"}}},{"name":"CreateChildTask2","type":"ElsaCleanSlate.Activities.CreateChildTask","result":{"typeName":"Object","memoryReference":{"id":"48241bec-839b-4d23-8483-fc9e856df3c5"}},"inputJson":{"typeName":"String","expression":{"type":"JavaScript","value":"JSON.stringify({Metadata:{TaskTitle:"Ap Task Type from Workflow"},EntityId:0,EntityTypeId:5,ParentTaskId:getVariable('RootTrigger').EntityId,ChildTaskTypeId:65})"}},"conditionJson":{"typeName":"String"},"id":"48241bec-839b-4d23-8483-fc9e856df3c5"},{"name":"RecordUpdated","type":"ElsaCleanSlate.Triggers.RecordUpdated","customProperties":{"canStartWorkflow":false,"runAsynchronously":false},"statusId":{"typeName":"Int16","expression":{"type":"Literal","value":0}},"fieldId":{"typeName":"String","expression":{"type":"Literal","value":""}},"entityTypeId":{"typeName":"Int16","expression":{"type":"Literal","value":5}},"taskTypeId":{"typeName":"Int32","expression":{"type":"Literal","value":65}},"entityId":{"typeName":"Int32","expression":{"type":"JavaScript","value":"getVariable('CreateChildTask2').EntityId"}},"id":"c7c6effb-1e91-47d1-a407-4ad87fedfd57"},{"name":"SendEmail3","type":"ElsaCleanSlate.Activities.SendEmail","result":{"typeName":"Object","memoryReference":{"id":"6e29a489-1804-43fe-b51b-6de0dddbb68a"}},"inputJson":{"typeName":"String","expression":{"type":"JavaScript","value":"JSON.stringify({Priority:0,IsAllowOnlyAssignedMembers:false,EmailTo:"[email protected]",ToGroups:"",ToRoles:"",AllowedCc:false,AllowedBcc:false,EmailCc:"",CcGroups:"",CcRoles:"",EmailBcc:"",BccGroups:"",BccRoles:"",EmailSubject:"Custom Subject ",EmailBody:"
Test mail
",EntityTypeId:5,EntityId:getVariable('CreateChildTask2').EntityId})"}},"conditionJson":{"typeName":"String"},"id":"6e29a489-1804-43fe-b51b-6de0ddd...✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.