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)

Visual Studio SSRS filter expression on enum parameter

(0) ShareShare
ReportReport
Posted on by

Hi all, so I want to make a filter based on enum parameters on my contract class

the condition:

I have customized Enum let say Custom1 has value 0 (Open), 1 (All) in class contract as parameter

and if Custom1 has value 0 (Open) then report only show record which has value SalesLine.SalesStatus == SalesStatus::Backorder

else show record with all SalesStatus value

so in the tablix filter I write:

Expression : =IIF(Parameters!Custom1_DynamicsParameter.Value = "Open", Fields!SalesStatus.Value, False)

Operator : <>

Value : Backorder

when i run the preview I got error :

"Cannot compare data types System.Boolean and System.String......"

what is the solution?

thanks in advance.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    Custom1_DynamicsParameter is returning you a Boolean value such as may be 0 or 1 and you are trying to compare it with a string  "Open"

    In addition, you can also  filter data inside RDP based on condition.

  • Community Member Profile Picture
    on at

    i've tried that it still throw errors.

    How to filter inside RDP? I've tried it but it seems no effect, maybe there's something wrong in my code?

    public void processReport()

    {

       contract = this.parmDataContract() as SalesStatusContract;

       salesid = contract.parmSalesID();

       noyes = contract.parmNoYes();

       customsalesenum = contract.parmcustomsalesenum();

       q = this.parmQuery();

       q.dataSourceTable(tableNum(SalesTable)).addRange(fieldnum(SalesTable, SalesId)).value(salesid);

       if(noyes == NoYes::No)

    {

       q.dataSourceTable(tableNum(ProdRouteTrans)).addRange(fieldnum(ProdRouteTrans,    TransRefID)).value(sysquery::valueNotEmptyString());

    }

    else

    {

       q.dataSourceTable(tableNum(ProdRouteTrans)).addRange(fieldnum(ProdRouteTrans,    TransRefID)).value(sysquery::valueunlimited);

    }

       if(customsalesenum == customsalesenum::open)

    {

       q.dataSourceTable(tableNum(SalesLine)).addRange(fieldnum(SalesLine, SalesStatus)).value(queryvalue(SalesStatus::Backorder));

    }

    else

    {

       q.dataSourceTable(tableNum(SalesLine)).addRange(fieldnum(SalesLine, SalesStatus));

    }

       qr = new QueryRun(q);

       while(qr.next())

       {

       }

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at

    Hi Ahau,

    processReport() is not a best place to do this. You should override preRunModifyContract(). Please refer to this blog post as an example

    msdax.wordpress.com/.../how-to-set-the-query-range-on-a-ssrs-report

  • Sohaib Cheema Profile Picture
    49,438 User Group Leader on at

    apparently it does not seems anything wrong, in your code.

    can you  debug to see what is your query at point of QueryRun

    if you don't want to put yourself into trouble of debugging you can insert query string into any table(which you can delete later)

    you can get query into string by following statement

    info(queryRun.query().toString());

    or else, enable debugging and debug RDP

    This can help us to know what's going on inside

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