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 :
Microsoft Dynamics AX (Archived)

cannot filter the not related item number in PurchTable form using related field fixed

(0) ShareShare
ReportReport
Posted on by 577

I set a related field fixed with 1(raw) == InventTable.CustProductType under Original relation InventTable and CustProductType is a Enum field. I set a 1(raw) for CustProductType of released product A. Then, when I select the item number in PurchTable form, all items came out. It is supposed that only items with CustProductType of 1(raw). Why all items came out?

*This post is locked for comments

I have the same question (0)
  • Sohaib Cheema Profile Picture
    49,677 Super User 2026 Season 1 on at

    I haven't opened AX VHD at moment but I can clearly remember that these lookups on sales and purchase forms are coming up dynamically. Behind the scene there are lookup forms and classes depending upon parameter setup.

    I would encourage you to have a code review and fix existing lookup code. changing relationship on PurchTable, may not have any impact on Lookup which is being built dynamically, as it is not knowing anything about PurchTable field fixed or any relationships.

  • Tony Mok Profile Picture
    577 on at

    Do you mean I should add my lookup code under the itemId field in the grid?

  • Verified answer
    Sohaib Cheema Profile Picture
    49,677 Super User 2026 Season 1 on at

    I mean, the existing lookups are appearing because of existing code. Merge your changes in existing code.

  • Tony Mok Profile Picture
    577 on at

    Ok, I see. I found there is lookup method for ItemId under data source of purchline. InventItemIdLookupPurchase is lookup form and I need to add my code in the run method.

  • Verified answer
    Sohaib Cheema Profile Picture
    49,677 Super User 2026 Season 1 on at

    I would like to highlight important part in my 1st reply on this thread and would repeat here again.

    Yes you are going in correct direction, but remember lookup code depends upon parameters, for this case.

    ============================

    If (SomeConditionForParameters)

    {

    //Lookup of items

    }

    Else

    {

    //Lookup of items, with some other conditions

    }

    ============================

    Make sure to put your changes in needed place and analyze impact if parameters are updated tomorrow

  • Verified answer
    Tony Mok Profile Picture
    577 on at

    I succeeded to filter the item in PurchTable, and my solution shows as follows:

    I add init() in the data source InventTable of InventItemIdLookupPurchase

    public void init()

    {

       Query                   query;

       QueryBuildDataSource    qbds;

       QueryBuildRange         qbrProductType;

       super();

       query = new Query();

       qbds = query.addDataSource(tablenum(InventTable));

       qbrProductType = qbds.addRange(fieldnum(InventTable, ProductType));

       qbrProductType.value(queryvalue(ProductType::RawMaterial));

       this.query(query);

    }

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!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Basit Profile Picture

Basit 1

#1
GL-01081504-0 Profile Picture

GL-01081504-0 1

#1
Roya Profile Picture

Roya 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans