How clear added previously added datasource and ranges in querybuildrange in ax 2012

Description:-

Here I have given simple demonstration to remove ranges from DataSource in Ax 2012. In form DataSource I have generated executeQuery method to changes ranges in DataSource based on combo box selection.

public class FormRun extends ObjectRun
{
    QueryBuildRange         QBR,QbrRMId,QbrSTId;
    QueryBuildDataSource    QbdsRM, QbdsST;
}

public void executeQuery()
{
    QbdsRM = DataSourceName_ds.query().dataSourceNo(1);
    QbdsST= DataSourceName_ds.query().dataSourceNo(1);
    if(FilterData.valueStr() == enum2str(EnumRM::All))
    {
        QbdsRM.clearRanges();
        QbdsST.clearRanges();
    }
    else if(FilterData.valueStr() == enum2str(EnumRM::RMId))
    {
        QbdsST.clearRanges();
        QbrSTId = sysQuery::findOrCreateRange(QbdsRM,fieldnum(DataSourceName, DataSourceField));
        QbrSTId.value(sysquery::valueEmptyString());
        QbdsRM.clearRanges();
        QbrRMId = sysQuery::findOrCreateRange(QbdsRM,fieldnum(DataSourceName, DataSourceField));
        QbrRMId.value(sysquery::valueNotEmptyString());
    }
    else if(FilterData.valueStr() == enum2str(EnumRM::STId))
    {
        QbdsRM.clearRanges();
        QbrRMId = sysQuery::findOrCreateRange(QbdsRM,fieldnum(DataSourceName, DataSourceField));
        QbrRMId.value(sysquery::valueEmptyString());
        QbdsST.clearRanges();
        QbrSTId = sysQuery::findOrCreateRange(QbdsRM,fieldnum(DataSourceName, DataSourceField));
        QbrSTId.value(sysquery::valueNotEmptyString());
    }
    super();
}

Combo box modified method.

public boolean modified()
{
    boolean ret;
    ret = super();
    DataSourceName_ds.executeQuery();
    return ret;
}

Related Posts

Previous
Next Post »

Thanks for comments.....