Create Custom lookup in AX 2012

Description:- 
Lookup is nothing but we can see easily other table data in other form or table. When we have to fill Marks data based on student Name or Student ID then we are storing Only ID Field in Column that time we have to See ID and Name in Lookup it Means Dropdown. So We Can Easily Select and Filled Data in Controls. Custom Lookup is nothing but codding through We Can Generate Lookup it Means Dropdown in Form.


Step 1: Create Table Name it “A_Student”.
  1. Expand AOT Node.
  2. Open Data Dictionary Node.
  3. Select Tables and right Click Select New Table.
  4. Name it “A_Student”.
  5. Now open table in Insert Some Data in A_Student table.

Step 2: Now Create Form and Name it “A_StudentForm”.
  1. Expand AOT Node.
  2. Select Form Node and Right Click Select New Form and Name it “A_ StudentForm”.
  3. Now Drag and Drop Table in Form DataSource.
  4. Select Design Node Right Click and Select NewControls & Add Grid Controls in Design Node. 

Step 3: Drag and drop DataSource Field in Grid Controls to See Data in Form. 



Step 4: Now select Cust_Account Field form Grid Controls and Override Lookup Method.


Step 5: Create Custom Code for Lookup and Create Query, QueryBuildDataSource, and QueryBuildRange and Perform Lookup in A_StudentForm.

Lookup Code:

public void lookup()
{
    Query                   query = new Query ();
    QueryBuildDataSource    qbds;
    QueryBuildDataSource    qbdsJoin;
    SysTableLookup          sysTableLookup = sysTableLookup::newParameters(tableNum(CustTable), this);
    ;
 
    qbds= query.addDataSource( tableNum(CustTable));
    sysTableLookup.parmQuery(query);
    sysTableLookup.addLookupfield( fieldNum(CustTable, AccountNum), true);
    sysTableLookup.addLookupfield( fieldNum(CustTable, Party));
    sysTableLookup.performFormLookup();
}

Step 6: Now Open A_Student Form to Open Right Click on Form and Select Open. 


Step 7: Now Select CustAccount Column to Open Custom Lookup.

Related Posts

Previous
Next Post »

Thanks for comments.....