Reset workflow templates no longer removes steps from active workflows#9601
Open
darjoo wants to merge 2 commits into
Open
Reset workflow templates no longer removes steps from active workflows#9601darjoo wants to merge 2 commits into
darjoo wants to merge 2 commits into
Conversation
…from active workflows ResetWorkflowTemplates deleted workflow steps filtered only by the 'MS-' template code prefix, which also matched active workflows created from templates (code MS-XYZ-01, Template=false), emptying them. Scope step/argument deletion to each template's exact Workflow Code so active workflows are never affected. Also add a confirmation dialog and clearer tooltip to the Reset Microsoft Templates action, plus regression tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
onbuyuka
previously approved these changes
Jul 20, 2026
Verify the confirm dialog fires exactly once with the expected question, per the UI-handlers-in-tests guidance. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What & why
Running Reset Microsoft Templates on the Workflow Templates page could wipe the steps out of active workflows, not just the templates. This is a Sev 1, data-loss defect (ADO Bug 640937) affecting customers with many workflows created from templates.
Root cause:
ResetWorkflowTemplates()in codeunit 1502 "Workflow Setup" deleted the workflow records correctly (scoped toTemplate = true), but deleted the workflow steps using a separate filter that matched only on theMS-template code prefix. A workflow created from templateMS-XYZgets codeMS-XYZ-01(Template = false, stillMS-prefixed), so its steps matched that filter and were deleted, leaving the active workflow an empty shell.The fix iterates the filtered template workflows and deletes steps/step-arguments only for each template's exact
Workflow Code, then deletes the templates. BecauseCodeis the primary key and a non-template can't reuse a template's exact code, scoping the deletion this way is provably safe. Workflows created from templates are never touched. As additional safety and clarity, the Reset action now asks for confirmation and has a clearer tooltip describing the corrected, templates-only behavior.Linked work
AB#640937
How I validated this
What I tested and the outcome
CopyWorkflowTests.Codeunit.al, both driving the real page action (so they also exercise the new confirmation dialog):TestResetTemplatesKeepsStepsOfWorkflowCreatedFromTemplate: creates a template plus a workflow copied from it (MS-...-01), runs Reset and confirms, then asserts the copied workflow still exists and keeps all its steps. This fails on the old code and passes with the fix.TestResetTemplatesIsSkippedWhenConfirmationDeclined: declines the confirmation and asserts nothing was reset.Library - Workflowhelper signatures, object visibility, and the surrounding AL. A container build and test run (Docker + BcContainerHelper + platform symbols) was not available in my environment, so those two boxes are intentionally left unchecked pending a local build/run of the Workflow test suite.Risk & compatibility
W1base layer; there are no country-layer overrides of these objects, so no Miapp propagation is required.