web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Filter Item Lookup in Sales Order and Purchase Order Subforms

(0) ShareShare
ReportReport
Posted on by 36

We added a customized category field in Item table and differentiate items of sale and purchase according to this field value. Now we have to filter item lookup in sales order and purchase order subform in NO. field by hardcoding category value in code when type = Item , so how we can do it?

I have the same question (0)
  • Suggested answer
    TabrezAjaz Profile Picture
    202 on at

    Hi Abdul Mateen,

    To filter the item lookup in sales order and purchase order subforms based on the customized category field, you can modify the codeunit that is responsible for handling the lookup for the item field.

    Here are the steps to achieve this:

    1. Identify the codeunit responsible for handling the item lookup in the sales order and purchase order subforms. The codeunit is typically named "Sales- or Purchase Line Item Subform Management."

    2. Open the codeunit in the development environment.

    3. Locate the function that is responsible for retrieving the list of items for the lookup. The function is typically named "GetItemList."

    4. Modify the function to filter the items based on the value of the customized category field.

    5. Save the changes to the codeunit and compile it.

    For example, if your customized category field is named "Item Category," you can modify the code as follows:

    --------------------

    ItemCategoryValue := 'Value to Filter';

    IF ItemRec.FINDSET THEN

     REPEAT

       IF ItemRec."No." <> '' THEN BEGIN

         ItemCategory := ItemRec."Item Category";

         IF ItemCategory = ItemCategoryValue THEN BEGIN

           ItemList.Add(ItemRec);

         END;

       END;

     UNTIL ItemRec.NEXT = 0;

    --------------------

    In the above code, "ItemCategoryValue" is the value of the customized category field that you want to filter by. Replace it with the appropriate value for your situation.

    Note that these changes will affect the item lookup in both the sales order and purchase order subforms, as they share the same codeunit.

  • Abdul Mateen Profile Picture
    36 on at

    can't find codeunit like this.

  • Suggested answer
    Valentin Castravet Profile Picture
    31,981 Super User 2026 Season 1 on at

    are you only categorizing your items based on if its for sale or for purchase, and nothing else? If its only that you can achieve what you're looking for with out of the box functionality.

    On the item card there are two fields, purchasing blocked and sales blocked. If an item is marked as purchasing blocked, it wont appear in the drop down in sales documents. If its marked as sales blocked, it wont appear in the drop down in purchase documents

    learn.microsoft.com/.../inventory-how-block-items

  • Abdul Mateen Profile Picture
    36 on at

    Actually its not only on sale and purchase , we have different categories so we have to filter item popup window on No. field according to category but thanks for the information.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,964 Super User 2026 Season 1

#2
Dhiren Nagar Profile Picture

Dhiren Nagar 1,086 Super User 2026 Season 1

#3
YUN ZHU Profile Picture

YUN ZHU 1,039 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans