Monday, 15 December 2014

Create simple Lookup method with range in Axapta



Program- 1
public void lookup(FormControl _formControl, str _filterStr)
{
   Query                   query          = new Query();
   QueryBuildDataSource    queryBuildDataSource;
  
   SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(CSL_AllDetails), _formControl);
   ;
   sysTableLookup.addLookupField(fieldNum(CSL_AllDetails, EmpId));
   sysTableLookup.addLookupField(fieldNum(CSL_AllDetails, EmpName));

   queryBuildDataSource = query.addDataSource(tableNum(CSL_AllDetails));
  
   sysTableLookup.parmQuery(query);
   sysTableLookup.performFormLookup();
}


Program-2
void lookup(FormControl _formControl, str _filterStr)
{
    Query                   query          = new Query();
    QueryBuildDataSource    queryBuildDataSource;
    QueryBuildRange         queryBuildRange;

    // Create an instance of SysTableLookup where 'this'
    // is the current form control.
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(custTable), _formControl);
    ;

    // Add fields to be shown in the lookup form.
    sysTableLookup.addLookupField(fieldNum(CustTable, AccountNum));
    sysTableLookup.addLookupField(fieldNum(CustTable, Name));

    // Limit and arrange the data selection.
    queryBuildDataSource = query.addDataSource(tableNum(CustTable));
    queryBuildRange = queryBuildDataSource.addRange(fieldNum(CustTable, AccountNum));
    queryBuildRange.value('A..B');
    sysTableLookup.parmQuery(query);

    // Perform the lookup.
    sysTableLookup.performFormLookup();

    //Don't call super() (commented out in the code).
    //   super()
}

No comments:

Post a Comment