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

Notifications

Announcements

No record found.

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 34

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
    34 on at

    can't find codeunit like this.

  • Suggested answer
    Valentin Castravet Profile Picture
    31,387 Super User 2025 Season 2 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
    34 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,151

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,443 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,092 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans