From 892862e068b874a4577ba02b9034db4e96463971 Mon Sep 17 00:00:00 2001 From: Luuk Date: Fri, 22 Sep 2023 12:13:18 +0200 Subject: [PATCH] #SetLoadFIelds --- .../docs/BestPractices/SetLoadFields/Index.md | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/content/docs/BestPractices/SetLoadFields/Index.md b/content/docs/BestPractices/SetLoadFields/Index.md index 465aea6f..684b751d 100644 --- a/content/docs/BestPractices/SetLoadFields/Index.md +++ b/content/docs/BestPractices/SetLoadFields/Index.md @@ -43,3 +43,27 @@ Item.SetLoadFields("Item Category Code"); Item.Get(ItemNo); ``` +Place the SetLoadFields in the code before the case statement +## Bad code + +```AL +Item.SetLoadFields("Item Category Code"); +ItemCategoryCode := FindItemCategoryCode; + +case true of + Item.Get(ItemNo): + SetItemCategoryCode(Item, ItemCategoryCode); +end; +``` + +## Good code + +```AL +ItemCategoryCode := FindItemCategoryCode; +Item.SetLoadFields("Item Category Code"); + +case true of + Item.Get(ItemNo): + SetItemCategoryCode(Item, ItemCategoryCode); +end; +```