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

Add filter option on field

(0) ShareShare
ReportReport
Posted on by 4

Hello Expertise,

Below form refer to Purchase order , here in Purchase order line in item field lookup i have added one customize field External item text . when i press Ctrl+G , data filtering option is activated on Item Number and Search Name which is highlighted with red arrow.

Now , I want To add same filter option on my Customize field  External item text . which is also looking with red arrow.

Please Suggest , How I can add filter option on External item text field.

6266.1.jpg

Thanks!

Regards

Naveen Mishra

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    What kind of field is the external item text? Memo?

  • Naveen Mishra Profile Picture
    4 on at

    Actually this field Path is -

    Product information management > Common> Released Product >On Action Pane ,Purchase Tab> External Item Description Form.

    Table Name - CustVendExternalItem

    Field Name - ExternalItemTxt

    Field Type - String

    Field EDT Name - ExternalItemFreeTxt

    3404.2.jpg

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    Is the table joined or are you using a display method? (You can't make queries against display methods.)

  • Naveen Mishra Profile Picture
    4 on at

    Yes, I am Using display method for this .

    I have write a display method in Invent Table.

    Then How i can add filter option , on my field.

    Please suggest.

  • Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    I already gave you one solution - if you join tables together, you can filter by the field.

  • Naveen Mishra Profile Picture
    4 on at

    Hi Martin Dráb,

    Thanks For Reply.

    As per your suggestion I have joined both table named InventTable and CustVendExternalItem  and Add my code in LookupItem  method which is already in Inventtable  for Showing Lookup in Field .

    So, Now  when i press CTRL+G , Filter option is showing  but it is any other field named Hight

    My field name is  ExternalItemID which  is not showing In lookup. you can see in below screenshot.

    0980.jpg

    I have added Below code in  LookupItem method .

    sysTableLookup.addLookupfield(fieldNum(CustVendExternalItem,ExternalItemId));

    Can you Please suggest for this issue.

    Thanks.

  • Suggested answer
    Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    It's because you're building the form at runtime using SysTableLookup class, which doesn't allow you to choose from which table the field should come. One of possible solutions is using SysMultiTableLookup.

  • Naveen Mishra Profile Picture
    4 on at

    Hi Martin Dráb

    Thanks For Suggestion.

    As per your given link I am writing below code in LookupItem method .

    public client static void lookupItem(FormStringControl _ctrl)
    {

    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    QueryBuildRange queryBuildRange;
    SysMultiTableLookup sysMultiTableLookup;
    queryBuildDataSource = query.addDataSource(tableNum(InventTable));
    queryBuildDataSource = query.addDataSource(tableNum(CustVendExternalItem));
    queryBuildDataSource.relations(true);

    sysMultiTableLookup = SysMultiTableLookup::newParameters(_ctrl,query);

    sysMultiTableLookup.addLookupfield(fieldNum(InventTable,ItemId));
    sysMultiTableLookup.addLookupMethod(tableMethodStr(InventTable,defaultProductName));
    sysMultiTableLookup.addLookupMethod(tableMethodStr(InventTable,itemGroupId));
    sysMultiTableLookup.addLookupfield(fieldNum(InventTable,NameAlias));
    sysMultiTableLookup.addLookupfield(fieldNum(InventTable,ItemType));
    sysMultiTableLookup.addLookupfield(fieldNum(InventTable,Product));
    sysMultiTableLookup.addLookupMethod(tableMethodStr(InventTable,displayExternalItemFreeTxt));
    sysMultiTableLookup.addLookupMethod(tableMethodStr(InventTable,displayExternalItemId));
    SysMultiTableLookup.addLookupfield(fieldNum(CustVendExternalItem,ExternalItemId));

    sysMultiTableLookup.parmQuery(query);
    sysMultiTableLookup.performFormLookup();
    }

    After Written this code when Click on Item Lookup on form I am Receiving below error , Pleases suggest  for below error.

    Error  -  "Queries with multiple top level data sources cannot be applied to Forms."

    Thanks.

  • Verified answer
    Martin Dráb Profile Picture
    237,882 Most Valuable Professional on at

    The bug is in query.addDataSource(tableNum(CustVendExternalItem)); it should be queryBuildDataSource.addDataSource(tableNum(CustVendExternalItem)). Or even better, you should use descriptive names for your variables, so it would be something like externalItemDs = inventTableDs.addDataSource(tableNum(CustVendExternalItem)).

    In addition, you forgot to specify the datasource in addLookupField() for ExternalItemId.

    ExternalItemId

  • Naveen Mishra Profile Picture
    4 on at

    Hi Martin Dráb

    Thanks For Suggestion.

    According to your suggestion i have written the code  , now code is compile without any error and item lookup field is working.

    But till now My field name is  ExternalItemID  is not showing In lookup. you can see in below screenshot.

    5700.0980.jpg

    Please suggest.

    Thanks 

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

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Sukrut Parab Profile Picture

Sukrut Parab 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans