Skip to main content

Filter records in form by code

Courtesy: http://dynamics-ax-live.blogspot.com/2010/03/how-to-filter-records-in-form-by-code.html
Step 1: Declare a class variable
In the ClassDeclaration method of the form, define a range.

QueryBuildRange CurrencyQBR;

Step 2: Instantiate the new range.
In the init method on the datasource of the form, you assign the range to a specific field (after the super call).

public void init()
{
super();

CurrencyQBR = this.query().dataSourceName('CustTable').addRange(fieldnum(CustTable,Currency));
}

Step 3: In the last step, you assign a value to the range.
This is done in the executeQuery method on the same datasource of the form. Before the super call. Like this:

public void executeQuery()
{ ;

CurrencyQBR.value(queryvalue('USD'));

super();
}

Comments

Popular posts from this blog

Run SSRS report using x++ code | AX 2012

This post describes how to run an SSRS report through x++ code and passing report parameters as well. Its a simple code and comments are added for further ease in code understanding! public static void runSSRSReport() {     SrsReportRunController controller;             controller = new SrsReportRunController();     controller.parmLoadFromSysLastValue(false);      // write report name and its design in quotes that you want to run     controller.parmReportName("ReportName.DesignName");      // set additional, optional properties like setting landscape to true     controller.parmReportContract().parmPrintSettings().landscape(true);          // set print destination screen/printer/file etc.     controller.parmReportContract().parmPrintSettings().printMediumType (SRSPrintMediumType::S...

Get Position and Department of an employee | AX 2012

A simple job to get position/designation and department of an employee using employee id: static void WorkerPositionDepartment(Args _args) {     HcmWorker                       hcmWorker;     HcmPositionWorkerAssignment     hcmPositionWorkerAssignment;     OMOperatingUnit                 oMOperatingUnit;     HcmPositionDetail               hcmPositionDetail;     HcmJob                          hcmJob;     HcmPosition             ...

Creating BOM journal using code AX 2012

courtesy: http://www.andesoft.net/creating-bom-journal-using-x-code-ax-2009-ax-2012/ https://community.dynamics.com/ax/f/33/t/96262.aspx http://learnax.blogspot.com/2010/01/x-code-to-create-and-post-inventory.html static void createBomJournal_working(Args _args) {     InventJournalTable      journalTable;     InventJournalTrans      journalTrans;     InventJournalTableData  journalTableData;     InventJournalTransData  journalTransData;     InventTable             inventTable;     InventDim               inventDim;     Counter                 cnt;     InventJournalCheckPost  journalCheckPost = new InventJournalCheckPost();     InventTransId           inventTransId, inventTransIdFather;     InventBat...