Skip to content

Reset workflow templates no longer removes steps from active workflows#9601

Open
darjoo wants to merge 2 commits into
mainfrom
darjoo-bug-640937-workflow-template-reset
Open

Reset workflow templates no longer removes steps from active workflows#9601
darjoo wants to merge 2 commits into
mainfrom
darjoo-bug-640937-workflow-template-reset

Conversation

@darjoo

@darjoo darjoo commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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 to Template = true), but deleted the workflow steps using a separate filter that matched only on the MS- template code prefix. A workflow created from template MS-XYZ gets code MS-XYZ-01 (Template = false, still MS- 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. Because Code is 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

  • I read the full diff and it contains only changes I intended.
  • I built the affected app(s) locally with no new analyzer warnings.
  • I ran the change in Business Central and confirmed it behaves as expected.
  • I added or updated tests for the new behavior, or explained below why none are needed.

What I tested and the outcome

  • Added two regression tests in 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.
  • Validated the change by reading the full diff and cross-checking it against the Library - Workflow helper 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

  • Behavior fix that stops data loss; no schema or upgrade impact.
  • Minor UX change: the Reset Microsoft Templates action now prompts for confirmation before running, and the tooltip/confirmation text are new user-facing strings (picked up by the generated translation file at build time).
  • Change is limited to the W1 base layer; there are no country-layer overrides of these objects, so no Miapp propagation is required.

…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>
@darjoo
darjoo requested a review from a team July 20, 2026 13:16
@github-actions github-actions Bot added the Integration GitHub request for Integration area label Jul 20, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone Jul 20, 2026
Comment thread src/Layers/W1/Tests/Workflow/CopyWorkflowTests.Codeunit.al Outdated
onbuyuka
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Integration GitHub request for Integration area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants