Monday, April 24, 2017

x++ code to disable filter in lookup code in Ax2012

Hi Folks,

After a long gap due to busy schedule..

Today,Lets learn small trick ,how to disable filter in lookup code in Ax2012

public void lookup(FormControl _formControl, str _filterStr)

{

    SysTableLookup          sysTableLookup;

    Query                   query;

    QueryBuildDataSource    qbds;

    QueryBuildRange         qbr;



    //super(_formControl, _filterStr);

    sysTableLookup  = SysTableLookup::newParameters(tableNum(InventTable),_formControl);

    sysTableLookup.addLookupfield(fieldNum(InventTable,ItemId));

    sysTableLookup.addLookupfield(fieldNum(InventTable,NameAlias));

    sysTableLookup.addLookupfield(fieldNum(InventTable,ItemType));



    query = new Query();

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

    qbr   = qbds.addRange(fieldNum(InventTable,ItemType));

    qbr.value(enum2str(ItemType::Service));

    qbr.status(RangeStatus::Hidden); //Itemtype Filter disable

    sysTableLookup.parmQuery(query);

    sysTableLookup.performFormLookup();



}



2 comments:

  1. I was Searching for this range filter on lookups and you made it simple.

    ReplyDelete
    Replies
    1. But is not working for Gender field .. it is just working for a normal string field like I use for my StudentId in this way
      qbr.value("S001")

      Delete

Export a copy of the standard user acceptance testing (UAT) database

 Reference link: Export a copy of the standard user acceptance testing (UAT) database - Finance & Operations | Dynamics 365 | Microsoft ...