Skip to content

[Shopify] Auto Create Catalog: always visible, validate plan on enable#8213

Open
onbuyuka wants to merge 3 commits into
mainfrom
bugs/630316-auto-create-catalog-plan-guard
Open

[Shopify] Auto Create Catalog: always visible, validate plan on enable#8213
onbuyuka wants to merge 3 commits into
mainfrom
bugs/630316-auto-create-catalog-plan-guard

Conversation

@onbuyuka
Copy link
Copy Markdown
Contributor

@onbuyuka onbuyuka commented May 19, 2026

Summary

Re-fix for bug 630316 after PM verification of PR #7605.

PR #7605 made B2B features unconditional on all Shopify plans, but the Auto Create Catalog toggle on the Customers and Companies group of the Shop Card stayed hidden for non-Advanced shops because its Visible = Rec."Advanced Shopify Plan" binding is not re-evaluated after GetShopSettings() flips the flag at runtime.

Per PM Andrei Pankos guidance:

  • Drop the dynamic visibility on the Auto Create Catalog field so its always visible in the Companies group.
  • Gate the field at the table layer instead: an OnValidate trigger raises a field error if the user tries to enable Auto Create Catalog on a shop whose plan does not support B2B catalogs (Plus, Plus Trial, Development, or Advanced).

The error uses the existing ErrorInfo / FieldNo pattern already used elsewhere in ShpfyShop.Table.al (e.g. field 21 Auto Create Orders).

What is NOT changed

  • action(Catalogs) (B2B Catalogs action) and action(StaffMembers) visibility on the Shop Card PM only flagged the field control.
  • The runtime Shop."Auto Create Catalog" checks in ShpfyCompanyAPI.Codeunit.al / ShpfyCompanyExport.Codeunit.al the table guard prevents the boolean from being set to true on an unsupported plan, so no runtime check is needed.
  • The B2B Enabled obsoletion and upgrade code from PR [Shopify] Remove B2B Plus-only plan restriction #7605 already accepted by PM.
  • app.json versions intentionally untouched.

Test

Adds TestAutoCreateCatalogRequiresAdvancedPlan to ShpfyStaffTest (codeunit 139551, which is already the home for Advanced Shopify Plan-gated tests). Verified both passes locally:

PASS TestStaffMembersActionVisibleOnlyForSupportedPlans (513ms)
PASS TestAutoCreateCatalogRequiresAdvancedPlan (23ms)

Fixes AB#630316

PR #7605 made B2B unconditional but the "Auto Create Catalog" toggle on
Shop Card stayed hidden for non-Advanced shops because its
`Visible = Rec."Advanced Shopify Plan"` binding is not re-evaluated after
GetShopSettings() runs.

Drop the dynamic visibility and gate the field at the table layer
instead: an OnValidate trigger raises a field error if the user tries to
enable Auto Create Catalog on a shop whose plan does not support B2B
catalogs.

Adds a test in ShpfyStaffTest (already the home for plan-gated tests)
covering both the rejection path and the success path after the plan
flag is set.

Fixes AB#630316

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@onbuyuka onbuyuka requested a review from a team as a code owner May 19, 2026 18:49
@github-actions github-actions Bot added the AL: Apps (W1) Add-on apps for W1 label May 19, 2026
@github-actions github-actions Bot added this to the Version 29.0 milestone May 19, 2026
Comment thread src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al Outdated
- Simplify the Auto Create Catalog OnValidate to use Error() with a
  StrSubstNo-style label instead of the heavier ErrorInfo pattern.

- Close the plan-downgrade gap flagged in PR review: GetShopSettings()
  now calls Rec.Validate("Advanced Shopify Plan", ...) instead of
  direct assignment, and field 207 has an OnValidate that auto-disables
  Auto Create Catalog (with a user message) when the plan is
  downgraded. Without the Validate switch the bot's suggested
  OnValidate would never fire from the actual API-sync path.

- Add TestAdvancedPlanDowngradeDisablesAutoCreateCatalog covering the
  downgrade path and a small MessageHandler.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al
Comment thread src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al Outdated
Silently disable Auto Create Catalog when Advanced Shopify Plan is
turned off; remove the now-unused label and test MessageHandler.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@onbuyuka onbuyuka enabled auto-merge (squash) May 19, 2026 20:39
Comment thread src/Apps/W1/Shopify/App/src/Base/Tables/ShpfyShop.Table.al
@github-actions
Copy link
Copy Markdown
Contributor

$\textbf{🟡\ Medium\ Severity\ —\ Style} \quad \color{gray}{\texttt{\small Iteration\ 1}}$

GetShopSettings missing Modify after Validate

GetShopSettings() now calls Rec.Validate("Advanced Shopify Plan", ...) which can cascade to Rec.Validate("Auto Create Catalog", false) in-memory, but the function does not call Rec.Modify(). The persisted Auto Create Catalog value depends entirely on the caller remembering to call Modify after GetShopSettings. If any caller path omits the Modify, the plan-guard cascade will silently fail to persist.

Recommendation:

  • Add Rec.Modify(true) at the end of GetShopSettings() to ensure all field changes (including cascaded ones) are persisted atomically within the function, or add a code comment explicitly documenting that the caller is responsible for Modify.
        Rec.Validate("Advanced Shopify Plan", JsonHelper.GetValueAsBoolean(JItem, 'shopifyPlus') or
                                                (JsonHelper.GetValueAsText(JItem, 'publicDisplayName') in ['Plus Trial', 'Development', 'Advanced']));
        Rec."Weight Unit" := ConvertToWeightUnit(JsonHelper.GetValueAsText(JResponse, 'data.shop.weightUnit'));
        Rec.Modify(true);
    end;

Line mapping was unavailable, so this was posted as an issue comment.

👍 useful · ❤️ especially valuable · 👎 wrong - reply with why

Comment thread src/Apps/W1/Shopify/Test/Staff/ShpfyStaffTest.Codeunit.al
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AL: Apps (W1) Add-on apps for W1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant