Interview Questions

Tuesday, September 27, 2016

lookup method in ax 2009

public void lookup(FormControl _formControl, str _filterStr)
{
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(ProdBOM), _formControl);
    Query query = new Query();
    QueryBuildDataSource qbds;
    QueryBuildRange  qbr;
    ;
    sysTableLookup.addLookupField(fieldnum(ProdBOM, itemid));
    sysTableLookup.addLookupMethod('itemName');
    qbds = query.addDataSource(tablenum(ProdBOM));
    if(Rejection_ProdId.valueStr())
    {
        qbds.addRange(fieldnum(ProdBOM, prodid)).value(Rejection_ProdId.valueStr());
    }
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

public void lookup()
{
    Query                   query = new Query();
    QueryBuildDataSource    qbdsItem;
    QueryBuildDataSource    qbdsInventTableModule;
    QueryBuildDataSource    qbdsInventItemLocation;
    QueryBuildRange         qbrModuleType;
    SysMultiTableLookup     sysTableLookup;
    ;
    qbdsItem = query.addDataSource(tableNum(InventTable));
    qbdsInventTableModule = qbdsItem.addDataSource(tableNum(InventTableModule), "Purch");
    qbdsInventTableModule.relations(true);
    qbdsInventTableModule.fetchMode(QueryFetchMode::One2One);
    qbrModuleType = qbdsInventTableModule.addRange(fieldNum(InventTableModule, ModuleType));
    qbrModuleType.value(queryValue(ModuleInventPurchSales::Purch));
  
    qbdsInventTableModule = qbdsItem.addDataSource(tableNum(InventTableModule), "Invent");
    qbdsInventTableModule.relations(true);
    qbdsInventTableModule.fetchMode(QueryFetchMode::One2One);           
    qbrModuleType = qbdsInventTableModule.addRange(fieldNum(InventTableModule, ModuleType));
    qbrModuleType.value(queryValue(ModuleInventPurchSales::Invent));
          
    qbdsInventTableModule = qbdsItem.addDataSource(tableNum(InventTableModule), "Sales");
    qbdsInventTableModule.relations(true);
    qbdsInventTableModule.fetchMode(QueryFetchMode::One2One);
    qbrModuleType = qbdsInventTableModule.addRange(fieldNum(InventTableModule, ModuleType));
    qbrModuleType.value(queryValue(ModuleInventPurchSales::Sales));
          
    qbdsInventItemLocation = qbdsItem.addDataSource(tableNum(InventItemLocation));
    qbdsInventItemLocation.relations(true);
    qbdsInventItemLocation.fetchMode(QueryFetchMode::One2One);
          
    sysTableLookup = SysMultiTableLookup::newParameters(this, query);
          
    sysTableLookup.addLookupField(fieldNum(InventTable, ItemId));
    sysTableLookup.addLookupField(fieldNum(InventTable, ItemName));
    sysTableLookup.addLookupMethod(tableMethodStr(InventTable, ConfigActive), 1, "Is configuration active?");
    sysTableLookup.addLookupField(fieldNum(InventTableModule, TaxItemGroupId), 2, false, "Purch Item Tax Group");
    sysTableLookup.addLookupField(fieldNum(InventTableModule, TaxItemGroupId), 3);
    sysTableLookup.addLookupField(fieldNum(InventTableModule, TaxItemGroupId), 4);
    sysTableLookup.addLookupField(fieldNum(InventItemLocation, CountGroupId), 5);
    sysTableLookup.performFormLookup();
}


public void lookup()

{
//super();


// Declaration
Query   LookupQuery    =   new Query();

QueryBuildDataSource     LookupQueryBuildDataSource;

QueryBuildRange                  LookupQueryBuildRange;
SysTableLookup CustomSysTableLookup =       SysTableLookup::newParameters(tableNum(CustTable), this);

;

// Add fields that you want in Lookups

CustomSysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));

CustomSysTableLookup.addLookupField(fieldNum(CustTable,Name));

LookupQueryBuildDataSource =

LookupQuery.addDataSource(tableNum(CustTable));

LookupQueryBuildRange=

LookupQueryBuildDataSource.addRange(fieldNum(CustTable,AccountNum));

//LookupQueryBuildRange.value(queryValue(NOYESCOMBO::Yes));

// Execute the Query

CustomSysTableLookup.parmQuery(LookupQuery);

CustomSysTableLookup.performFormLookup();
}

public void lookup(FormControl _formControl, str _filterStr)
{
SysTableLookup sysTableLookup; // systemclass to create //customlookup
Query query;
QueryBuildDataSource qbd;
;
sysTableLookup = SysTableLookup::newParameters(
tablenum(InventTable),
_formcontrol);

// Construct query on the table,
// whose records you want to show as lookup.
query = new Query();
qbd = query.addDataSource(tablenum(InventTable));
qbd.addRange(fieldnum(InventTable,ItemType)).value(SysQuery::value(enum2str
(ItemType::Item)));

// add the fields to the lookup list
sysTableLookup.addLookupfield(fieldnum(InventTable,ItemId));
sysTableLookup.addLookupfield(fieldnum(InventTable,ItemName));

// pass the query as parameter
// system will show the records in the lookup
// as per your query
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();

}

public void lookup()
 {
     //This lookup basis the list criteria on information in 2 tables
     //All display fields come from Table1, Table2 is used for limiting criteria
    
     //super();
    
     //This Next Line initializes the the sysTableLookupClass
     sysTableLookup          sysTableLookup  =
                     SysTableLookup::newParameters(tableNum(<TABLENAME1>), this);
    
     Query                   query           = New Query();
     QueryBuildDataSource    qbdsTbl1, qbdsTbl2;
     QueryBuildRange         qbr;
     ;
    
     //Add Tables to the data source
     qbdsTbl1      = query.addDataSource(tableNum(<TABLENAME1>));
     qbdsTbl2     = qbdsTbl1.addDataSource(tableNum(TABLENAME2));


     //Add Query Ranges to limit List records   
     qbr = qbdsTbl1.addRange(fieldNum(<TABLENAME1>,<RANGEFIELDNAME1>));
     qbr.value(<CRITERIAVALUE>);

     qbr = qbdsTbl1.addRange(fieldNum(<TABLENAME1>, <RANGEFIELDNAME2>));
     qbr.value(<CRITERIAVALUE>);

     qbr = qbdsTbl1.addRange(fieldNum(<TABLENAME1>, <RANGEFIELDNAME3>));
     qbr.value(<CRITERIAVALUE>);
    
     //Since we have multiple tables in the query turn on relations
     qbdsTbl1.relations(true);

     //Add Ranges to the Table2
     qbr = qbdsTbl2.addRange(fieldNum(<TABLENAME2>, <RANGEFIELDNAME4>));
     qbr.value(<CRITERIAVALUE>);
    
     qbdsTbl2.relations(true);

     //The next 2 lines actualy adds the fields that will be displayed in the lookup grid
     sysTableLookup.addLookupfield(fieldNum(<TABLENAME1>, <DISPLAYFIELDNAME>));
     sysTableLookup.addLookupfield(fieldNum(<TABLENAME1>, <DISPLAYFIELDNAME>));
    
     //Hand the created query to the sysTableLookupClass
     sysTableLookup.parmQuery(query);

     //Display the drop down
     sysTableLookup.performFormLookup();

 }




Another example single table with field and table names instead of variable place holders



//Single table example with actual table and field names instead of  place holders
 public void lookup()
 {
     //This lookup basis the list criteria on information in 2 tables
     //super();
     sysTableLookup          sysTableLookup  =
                 SysTableLookup::newParameters(tableNum(salesBillOfLadingJournalTable), this);
     Query                   query           = New Query();
     QueryBuildDataSource    qbdsJT, qbdsBLR;
     QueryBuildRange         qbr;
     ;

     qbdsJT      = query.addDataSource(tableNum(salesBillOfLadingJournalTable));
     qbdsBLR     = qbdsJT.addDataSource(tableNum(salesBLReservation));



     qbr = qbdsJT.addRange(fieldNum(salesBillOfLadingJournalTable,isMaster));
     qbr.value(enum2str(noYes::No));

     qbr = qbdsJT.addRange(fieldNum(salesBillOfLadingJournalTable, custAccount));
     qbr.value((salesBillOfLadingJournalTableMaster.CustAccount));

     qbr = qbdsJT.addRange(fieldNum(salesBillOfLadingJournalTable, masterBLID));
     qbr.value(&quot;&quot;&quot;&quot;);

     qbdsJT.relations(true);

     qbr = qbdsBLR.addRange(fieldNum(salesBLReservation, blOpen));
     qbr.value(enum2str(noYes::Yes));
     qbdsBLR.relations(true);

     sysTableLookup.addLookupfield(fieldNum(salesBillOfLadingJournalTable, BillOfLadingID));
     sysTableLookup.addLookupfield(fieldNum(salesBillOfLadingJournalTable, salesID));
     sysTableLookup.parmQuery(query);

     sysTableLookup.performFormLookup();

 }


public void lookup()
{
    Query   LookupQuery    =   new Query();
    QueryBuildDataSource     LookupQueryBuildDataSource;
    QueryBuildRange                  LookupQueryBuildRange;
    SysTableLookup ItemSysTableLookup =       SysTableLookup::newParameters(tableNum(InventLocation), this);
    ;
    ItemSysTableLookup.addLookupField(fieldNum(InventLocation, InventLocationId));
    ItemSysTableLookup.addLookupField(fieldNum(InventLocation, Name));
    ItemSysTableLookup.addLookupField(fieldNum(InventLocation, InventSiteId));
    LookupQueryBuildDataSource =LookupQuery.addDataSource(tableNum(InventLocation));
    LookupQueryBuildRange=LookupQueryBuildDataSource.addRange(fieldNum(InventLocation,InventSiteId));
    LookupQueryBuildRange.value(queryRange(Site.valueStr(),Tosite.valueStr()));
    ItemSysTableLookup.parmQuery(LookupQuery);
    ItemSysTableLookup.performFormLookup();
}


public void lookup()
{
    Query   LookupQuery    =   new Query();
    QueryBuildDataSource     LookupQueryBuildDataSource;
    QueryBuildRange                  LookupQueryBuildRange;
    SysTableLookup ItemSysTableLookup =       SysTableLookup::newParameters(tableNum(InventItemGroupItem), this);
    ;
    ItemSysTableLookup.addLookupField(fieldNum(InventItemGroupItem, ItemId));
    ItemSysTableLookup.addLookupMethod('itemName');
    ItemSysTableLookup.addLookupField(fieldNum(InventItemGroupItem, ItemGroupId));
    LookupQueryBuildDataSource =LookupQuery.addDataSource(tableNum(InventItemGroupItem));
    LookupQueryBuildRange=LookupQueryBuildDataSource.addRange(fieldNum(InventItemGroupItem,ItemGroupId));
    LookupQueryBuildRange.value(queryRange(ProductGroup.valueStr(),ToProdGroup.valueStr()));
    ItemSysTableLookup.parmQuery(LookupQuery);
    ItemSysTableLookup.performFormLookup();
}

2 comments:

  1. Great post! A well-written resource to anyone looking to boost their microsoft dynamics Ax knowledge. The explanation is clear and gives a better understanding lookup method and i find there is a long way in making the entire process much more efficient and effective. I refer to this online resource http://tekslate.com/microsoft-dynamics-ax-training/ when gets stucked with a doubt on Ax.

    ReplyDelete
  2. Oracle SOA suite is a comprehensive, standards-based software suite to build, deploy and manage integration following the concepts of Service-Oriented Architecture (SOA). SOA fallows principles like Reuse, Loosely coupled, Interoperability and also it fallows all open standards so that SOA becomes hot in the market for integrating different systems/applications.
    Oracle SOA supports:
    Invocation, Routing, Mediation, Message Exchange patterns, Adapters, Transformation, Security, Governance, Process Choreography, Service Orchestration, Event Processing, Management,

    We provide best Oracle SOA 12c online training based on your flexible timings and Cost Effective and Flexible Payment Schemes.
    Please feel free to visit my site Oracle SOA 12c online training

    ReplyDelete