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)

AOT Query - Adding a 'case' Statement

(0) ShareShare
ReportReport
Posted on by 2,459

hi

is it possible to add a 'CASE' statement to an AOT Query?

*This post is locked for comments

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

    Short answer is No.

    But there are workarounds you can adopt. For example you can create a view inside AX AOT where you can have computed column with CASE statement. Finally you can use this view in your query. if you will use same table as DataSource, as the one in your current query, RecId(s) will be same in view as those are in table currently.

    This should provide you enough room to get your thing done.

  • SU-22040800-0 Profile Picture
    2,459 on at

    Hi Crispin - thanks for the response.

    I'm new to this, and can create basic Queries.. but now need to add a CASE statement.

    Would you be able to guide me on doing the Query init() method..?

  • SU-22040800-0 Profile Picture
    2,459 on at

    I have a SQL statement like the below, that i want to incorporate into a Grid FORM:

    SELECT

    T.ITEMID AS [PRODUCT ID],

    T.NAMEALIAS AS [SEARCH NAME],

    T1.NAME AS [PRODUCT NAME],

    CASE

    WHEN L.WMSLOCATIONID IN ('HISTORY', 'CROSSDOCK', 'PACKING') THEN 0

    WHEN D .INVENTSTATUSID <> 'AVAILABLE' THEN 0

    ELSE S.AVAILPHYSICAL

    END AS [AVAILABLE PHYSICAL],

    M.PRICE AS [PRICE PER ITEM],

    W.MULTIPLEQTY AS [PACK SIZE]

    FROM INVENTTABLE AS T LEFT OUTER JOIN

    INVENTSUM AS S ON T.ITEMID = S.ITEMID LEFT OUTER JOIN

    INVENTDIM AS D ON S.INVENTDIMID = D.INVENTDIMID LEFT OUTER JOIN

    WMSLOCATION AS L ON D.INVENTLOCATIONID = L.INVENTLOCATIONID AND D.WMSLOCATIONID = L.WMSLOCATIONID LEFT OUTER JOIN

    INVENTTABLEMODULE AS M ON T.ITEMID = M.ITEMID AND M.MODULETYPE = 2 LEFT OUTER JOIN

    INVENTITEMSALESSETUP AS W ON T.ITEMID = W.ITEMID AND W.INVENTDIMID = 'ALLBLANK' LEFT OUTER JOIN

    ECORESPRODUCT AS E1 ON T.PRODUCT = E1.RECID LEFT OUTER JOIN

    ECORESPRODUCTTRANSLATION AS T1 ON T1.PRODUCT = E1.RECID

    WHERE (L.INVENTLOCATIONID IS NOT NULL)

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

    I am afraid of performance reasons for doing anything like row based operations. I am not sure how efficient it can be to work with init() But with pre-built views its always fast.

    For examples, we can refer to many existing views in AX. e.g. have a look at next path

    \Data Dictionary\Views\WorkerTaskProjectsMatchView

  • SU-22040800-0 Profile Picture
    2,459 on at

    Thanks for the report Crispin - I trust you had a good weekend :)

    The above unfotunately will not help me.. Because the the result will NOT SHOW the items linked to those locations. I still want the items to show, but to show a QTY of zero.. Hence the use of CASE, and not just merley putting it into the WHERE clause.

    Any ideas how this can be done in AX?

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
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
Ali Zaidi Profile Picture

Ali Zaidi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans