Skip to main content

Notifications

Small and medium business | Business Central, N...
Suggested answer

Filter Item Lookup in Sales Order and Purchase Order Subforms

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?

  • Abdul Mateen Profile Picture
    Abdul Mateen 34 on at
    RE: Filter Item Lookup in Sales Order and Purchase Order Subforms

    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.

  • Suggested answer
    Valentin Castravet Profile Picture
    Valentin Castravet 24,793 Super User 2024 Season 2 on at
    RE: Filter Item Lookup in Sales Order and Purchase Order Subforms

    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
    Abdul Mateen 34 on at
    RE: Filter Item Lookup in Sales Order and Purchase Order Subforms

    can't find codeunit like this.

  • Suggested answer
    TabrezAjaz Profile Picture
    TabrezAjaz 190 on at
    RE: Filter Item Lookup in Sales Order and Purchase Order Subforms

    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.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans