[Master]-Contoso - The binding of codeunit 11489 was unsuccessful. The codeunit has already been bound. - Copy - #9971
Conversation
…icense Fees/Royalties)
|
| begin | ||
| TempContosoGLAccount.Get(AccountName); | ||
| exit(TempContosoGLAccount."Account No."); | ||
| if TempContosoGLAccount.Get(AccountName) then |
There was a problem hiding this comment.
GetAccountNo is a public procedure (called from many other codeunits: CreateFAGLAccount, CreateMfgGLAccount, CreateGLAccount, etc.) that previously guaranteed either a valid Account No. or a runtime error via TempContosoGLAccount.Get(AccountName). After this change, if the account name is not found in the temp buffer AND LoadAccountFromGLAccount also fails to find a matching G/L Account by Name, GetAccountNo falls through silently and returns an empty/default Code[20] instead of raising an error. This is a behavioral change to a published procedure's contract: callers that assumed a non-blank result or an explicit failure can now silently receive a blank account number, letting invalid/blank G/L account references propagate into demo-data setup without any error surfacing (e.g., into InsertGLAccount-adjacent calls or downstream posting-group wiring), producing confusing failures far from the actual missing-account cause. Consider re-raising an error (or returning the original TempContosoGLAccount.Get failure) when both lookups miss, or explicitly documenting/handling the blank-return case at each call site.
Suggested fix (apply manually — could not be anchored as a one-click suggestion):
procedure GetAccountNo(AccountName: Text[100]): Code[20]
begin
if TempContosoGLAccount.Get(AccountName) then
exit(TempContosoGLAccount."Account No.");
if LoadAccountFromGLAccount(AccountName) then
exit(TempContosoGLAccount."Account No.");
TempContosoGLAccount.Get(AccountName);
end;Agent judgement — not directly backed by a BCQuality knowledge article.
👍 useful · ❤️ especially valuable · 👎 wrong - reply with why · AL review agent v1.31.4
Predrag Maricic (PredragMaricic)
left a comment
There was a problem hiding this comment.
S1 (High): The linked bug is caused by manual subscribers remaining bound when demo-data generation fails. This change only avoids one specific NET INCOME lookup failure. US Contoso Localization still binds codeunit 11489 in OnBeforeGeneratingDemoData and only unbinds it in OnAfterGeneratingDemoData, so any other exception still leaves the subscriber bound and the next run fails with the same error. Please fix the binding lifecycle and add a regression test that forces generation to fail, then verifies a second run does not report an already-bound codeunit.
S2 (High): GetAccountNo previously guaranteed a valid account number or raised an explicit lookup error. If neither the temporary mapping nor a G/L Account name matches, the new implementation falls through and returns blank, allowing invalid account references to propagate. Preserve explicit failure when both lookups miss.
s1 fixed but generally test was not found for demodata |
Predrag Maricic (PredragMaricic)
left a comment
There was a problem hiding this comment.
Reviewed the idempotent subscription-binding change for rerunning Contoso generation after an earlier failure.
There was a problem hiding this comment.
Pull request overview
This PR updates the US Contoso demo dataset localization subscriber binding logic to avoid failing when a subscriber codeunit is already bound during demo data generation.
Changes:
- Updated
OnBeforeGeneratingDemoDatato callBindSubscription(...)via its Boolean-returning form (if BindSubscription(...) then;) across all modules. - This makes subscription binding tolerant to “already bound” situations (the likely source of the reported runtime error for codeunit 11489 / “Create Acc. Schedule Line US”).
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
AB#645158