Fix undefined menuName in saveWizard when using provided menuId

The menuName variable was only defined in the else branch (new menu
creation) but referenced later in category logging. Now looks up the
menu name from DB when using a provided menuId.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Mizerek 2026-01-28 17:54:16 -08:00
parent 8086065d38
commit 3613776ff3

View file

@ -294,7 +294,10 @@ try {
// Use provided menuId (add-menu mode) or create/find menu
if (providedMenuId > 0) {
menuID = providedMenuId;
response.steps.append("Using provided menu ID: " & menuID);
// Look up the menu name for logging
qMenuName = queryExecute("SELECT MenuName FROM Menus WHERE MenuID = :id", { id: menuID }, { datasource: "payfrit" });
menuName = qMenuName.recordCount > 0 ? qMenuName.MenuName : "Menu " & menuID;
response.steps.append("Using provided menu: " & menuName & " (ID: " & menuID & ")");
} else {
// Create a Menu record for this business (or get existing menu with same name)
menuName = structKeyExists(wizardData, "menuName") && isSimpleValue(wizardData.menuName) && len(trim(wizardData.menuName))