Wednesday, 29 January 2014

Filter Records Based On Unbound Controls in Ax 2012

1. In the AOT, expand Forms, and then expand the form where you want to add fields to the filter group.
2. Expand Designs, expand Design,  click New Control, and then click the type of control you want to use. The control is         added to the group.
3. Expand the control node, right-click Methods, click Override methods, and then click LookUp. 
public void lookup()
{
    QueryBuildDataSource qbds;
    Query query = new Query();
    SysTableLookup sysTableLookup;
    super();
    sysTableLookup = SysTableLookup::newParameters(tableNum(Table1),this);
    qbds = query.addDataSource(tableNum(Table1));
    sysTableLookup.addLookupfield(fieldNum(Table1, RelatedId));
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}
In the same Control, right-click the Methods, click Override method, and then click modified
public boolean modified()
{
    boolean ret;
    ret = super();
    Table1_ds.executeQuery();
    return ret;
}

4. Expand the Methods node of the form, right-click classDeclaration,
public class FormRun extends ObjectRun
{
    QueryFilter queryFilter;
}
5. Expand the Data Sources node, and then find the table that has the field that has the      values that you will use to filter the list.
6. Expand the table node, right-click Methods, click Override method, and then click init. 
public void init()
{
    super();
    queryFilter = Table1_ds.query().addQueryFilter(Table1_ds.queryBuildDataSource(),"relatedID");
}
In the same table, right-click the Methods, click Override method, and then click executeQuery
public void executeQuery()
{
    queryFilter.value(element.design().controlName("StringEdit").valueStr());
    super();
}

No comments:

Post a Comment