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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How i can return a condition in a method? Is possible?

(0) ShareShare
ReportReport
Posted on by 578

I use 'IN' a lot, and I want to create a function that allows me to put less code. Is it possible to return certain conditions to a query from a method?

This is my requirement as an example

Capturaff.PNG


Thanks in advance!

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    BrandonSA Profile Picture
    1,673 on at

    Hi ismaelivan

    I would highly suggest you use a different method to create queries.

    Check this out:

    docs.microsoft.com/.../how-to-create-queries-by-using-x

    I don't think that particular query of yours will ever work... A Sales Id can never be more than 1 value, so you would probably want to use an 'or' operator, not an 'and' operator.

    But as I said, there are better ways to write queries.

    What exactly is your requirement? I'm guessing you're not going to hardcode a bunch of sales ids.

  • ismaelivan Profile Picture
    578 on at

    Thanks BrandonSA you are right is "||" jeje, but was only a example,

    I basically need a method to make IN(), because IN() isn't supported by any version of Dynamics AX.

    I read this post blogs.msdn.microsoft.com/.../new-capability-in-x-the-in-operator but I think the information is incorrect.

  • Verified answer
    Sukrut Parab Profile Picture
    71,741 Moderator on at

    In operator is not supported in Ax 2012 . Its supported in D365 for operations in PU 16 , so the information is correct its not just for version you are looking for.

  • Blue Wang Profile Picture
    Microsoft Employee on at

    Hi Ismaelivan:

    As you know, IN() is not supported.
    you should add range to meet your needs.
    You can refer to Microsoft Docs: https://docs.microsoft.com/en-us/dynamicsax-2012/developer/using-expressions-in-query-ranges

  • Martin Dráb Profile Picture
    239,632 Most Valuable Professional on at

    I wouldn't try to build a long text for a query range. I would create a method which will add one query range for every given value.

    Also note that IN() in D365FO doesn't support string fields, at least not at the moment.

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 24

#2
Michel ROY Profile Picture

Michel ROY 14

#3
Jagadabi Profile Picture

Jagadabi 6

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans