web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How To Apply Filters Without Being Mandatory in my SSRS Report? DP Class

(0) ShareShare
ReportReport
Posted on by 1,036

Hello awesome community!

I'm still practicing AX and report development, I'm having trouble with filters in SSRS report.

I'm using a DP class, everything works fine as of inserting data in my temp table, showing results in the report I designed in Visual Studio and displaying filters on report, but my problem is I don't know how to make the filters NOT MANDATORY in the report. Please, take a look at my code and your help for this newbie will be appreciated :)

DP Class, processReport() Code: 

Help-2.PNG 

As you can see the commented code part, it applied the filter in showing results but it was mandatory (once you open the report, it won't show any results unless you type a true value in the filter ), I want the report to show up all results but if the user wanted to use filters, he can use the filter optionally.

Thank you.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Instead of query range, you can add a custAccount field to your contract class and use queryRun instead of a regular query.

    Refer following link to implement using contract class and DP class:

    (Developing a SSRS report using the Report Data Provider in Microsoft Dynamics AX 2012)

    community.dynamics.com/.../developing-a-ssrs-report-using-the-report-data-provider-in-microsoft-dynamics-ax-2012

  • Verified answer
    Chaitanya Golla Profile Picture
    17,225 on at

    Hi,

    Your code would typically look like below:

    In DP class, processReport method:

    Query query = new Query();
    QueryBuildDataSource qbds1, qbds2;
    QueryRun queryRun;
    
    CustContract contract = this.parmDataContract(); // Specify your contract class name
    
    qbds1 = query.addDatasource(tablenum(SalesTable));
    qbds2 = qbds1.addDatasource(tablenum(SalesLine));
    qbds2.joinMode(JoinMode::InnerJoin); qbds2.relations(true); if (contract.parmCustAccount()) { custAccount = contract.parmCustAccount(); SysQuery::findOrCreateRange(qbds1, fieldNum(SalesTable, InvoiceAccount)).value(queryvalue(custAccount)); } QueryRun = new QueryRun(query); while (QueryRun.next()) { //Your code to insert temporary table }
  • shubhi gupta Profile Picture
    405 on at

    Hi,

    Open VS->>Report->>Parameters>>Properties->>Behavior

    which parameter you want to not mandatory ,change two things

    1.Allow blank -true

    2.Nullable -true

  • Verified answer
    Momochi Profile Picture
    1,036 on at

    Thank you Chaitanya Golla for taking the time to help!

    I figured a way out to do it and it worked perfectly, please have a look at my added code:

    5353.Result-1.PNG 

    I used booleans for the filters input so if the user did not type anything it won't effect the "where" condition of the query, and if the user has typed something in the filter, the "where" condition will be effected using what the user has typed in the filter input. (Sorry for my bad English)

    I did not use the query run because I still don't understand how it works. Will check out the link you gave me :)

    Thanks again for your effort!

  • Momochi Profile Picture
    1,036 on at

    Thank you Shubhi Gupta! but this was not my problem, i'm sorry if I was not clear enough. You can check out how I did solve it in my last reply. Thanks again! :D

  • Momochi Profile Picture
    1,036 on at

    I tested your code, it works too thanks!

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans