Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

AX 2012 Create Form Filter

Posted on by 305

Hello All,

I had a Query Form,

I create a radio button for user to selected filter.

When user choose radio button 1 : filter the SalesQuotationTable's CustAccount.

When user choose radio button 2 :filter the SalesQuotationLine's ItemId.

but I can't change the filter between SalesQuotationTable's CustAccount and SalesQuotationLine's ItemId.

always filter the SalesQuotationLine's ItemId even choose the radio button1.

Please help and thanks a lot.

==================================

My code:

1. radio button1:

public boolean modified()
{
boolean ret;

ret = super();

SalesQuotationTable_1_ds.executeQuery();


return ret;
}

2.radio button2:

public boolean modified()
{
boolean ret;

ret = super();

SalesQuotationTable_1_ds.executeQuery();

return ret;
}

3. button

void clicked()
{

super();

SalesQuotationTable_1_ds.executeQuery();

SalesQuotationTable_1_ds.research();
SalesQuotationTable_1_ds.reread();

}

4. Form:

public class FormRun extends ObjectRun
{
QueryFilter queryFilter;
}

5. DataSource: SalesQuotationTable_1

init:

public void init()
{
super();

if (Option.selection() == 0)
{
queryFilter = SalesQuotationTable_1_ds.query().addQueryFilter(SalesQuotationTable_1_ds.queryBuildDataSource(),"CustAccount");
}
else if (Option.selection() == 1)
{
queryFilter = SalesQuotationLine_1_ds.query().addQueryFilter(SalesQuotationLine_1_ds.queryBuildDataSource(),"ItemId");
}
ProdId.visible(false);

}

executeQuery():

public void executeQuery()
{
this.query().dataSourceName(SalesQuotationTable_1_ds.name()).clearRange(fieldnum(SalesQuotationTable, CustAccount));

this.query().dataSourceName(SalesQuotationLine_1_ds.name()).clearRange(fieldnum(SalesQuotationLine, ItemId));

if (Option.selection() == 0)
{
this.query().dataSourceName(SalesQuotationTable_1_ds.name()).addRange(fieldnum(SalesQuotationTable, CustAccount))
.value(queryValue(queryFilter.value (element.design().controlName("CNum").valueStr())));

// queryFilter.value (element.design().controlName("CNum").valueStr());
}
else if (Option.selection() == 1)
{

this.query().dataSourceName(SalesQuotationLine_1_ds.name()).addRange(fieldnum(SalesQuotationLine,ItemId))
.value(queryValue(queryFilter.value (element.design().controlName("ProdId").valueStr())));
//queryFilter.value (element.design().controlName("ProdId").valueStr());

}
super();
}

 

*This post is locked for comments

  • Suggested answer
    BrandonSA Profile Picture
    BrandonSA 1,669 on at
    RE: AX 2012 Create Form Filter

    Hi

    You need to rearrange your code. You've got code all over the place. Maybe you should have an updateQuery() method or something like that. Try to keep code out of the executeQuery method.

    I can see a few mistakes here:

    - you're using queryFilters AND queryRanges

    - in your executeQuery method you're always adding a range. Every time you call that method, you're going to add a range. You should rather check if the range exists, and then find it if it exists using if (this.queryBuildDataSource().findRange(...

    - instead of using this.query().datasourcename(), rather use this.queryBuildDataSource().

    Hope this helps. Try some of these and see how you go

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans