DAXSPOT

Showing posts with label form lookup. Show all posts
Showing posts with label form lookup. Show all posts

Tuesday, May 21, 2019

Lookup in form string control

Hi,
Below is an example of the lookup in form string control.
First Go to the string control and override the lookup method, then copy the below code. Change the code as per your requirement.
public void lookup()
{
    Query query;
    QueryBuildDataSource datasourceModule;
    QueryBuildDataSource datasourceLanguage;
    QueryBuildRange rangeElementType;
    QueryBuildRange rangeModuleId;
    SysTableLookup sysTableLookup;
 
    query = new Query();
//Add table in Query build datasource
    datasourceLanguage = query.addDataSource(tableNum(SalesTable));
//pass a range, here i need salesOrder with Backorder status only   
    datasourceLanguage.addRange(
        fieldNum(SalesTable, SalesStatus)).value(queryValue(SalesStatus::BackOrder));
//add the lookup table
    sysTableLookup = SysTableLookup::newParameters(tableNum(SalesTable), this);

//Add which field to show in lookup
    sysTableLookup.addLookupfield(fieldNum(SalesTable, SalesId));

//add the above build query to the lookup Query
    sysTableLookup.parmQuery(query);

//at last perform the lookup.
    sysTableLookup.performFormLookup();

}

Monday, May 20, 2019

Display number of years in a lookup

Hi,

Today i got a requirement to show number of years in lookup.
This post will help you to show specific number of years in a look up.


public void lookup()
{
    Counter yearCount;
    List    valueList = new List(Types::String);

    for (yearCount = 0; yearCount < 5; yearCount++) //here 5 is number of years to show
    {
        valueList.addEnd(strFmt("Year %1", year(SystemDateGet()) - yearCount)); //getting system date year and minus with the count and add in list
    }

    SysLookup::lookupList(this, valueList, "List of years");
}


Happy Daxing! 😃

How to execute SQL directly form Dynamics AX X++

How to execute Sql directly form Dynamics AX X++ Reference by : alirazazaidi Dynamics Ax provide many other ways to communicate with databas...