Tuesday, 23 June 2015

How to override lookup in Microsoft Dynamics AX 2012

Here is the code
  • Method you need to define:
void DemoLookup(FormControl ctrl)
{
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(#TableName),ctrl);
    Query query = New Query();
    QueryBuildDataSource queryBuildDataSource = query.addDataSource(tableNum(#TableName));
    QueryBuildRange queryBuildRange;
    
    sysTableLookup.addLookupfield(fieldNum(#TableName, #FieldName));
    
    queryBuildRange = queryBuildDataSource.addRange(fieldNum(#TableName, #FieldName));
    queryBuildRange.value(queryValue(#Field Range);
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

  • In the form override the lookup method:
public void lookup()
{
    element.SummaryProjectLookup(this);
}

No comments:

Post a Comment