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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Date Computed Column in View

(0) ShareShare
ReportReport
Posted on by 1,214

Hi. I'm getting the latest VendPurchOrderJour.PurchOrderDate for a Date computed column in a view. 

I do this because I want this field to be able for sorting when it's used in a grid.

Here is the original query in it's display method. Since I only want the latest date, I select firstonly and sort it in descending order:

select firstOnly PurchOrderDate from vendPurchOrderJour
Order by vendPurchOrderJour.PurchOrderDocNum desc
where vendPurchOrderJour.PurchId == purchTable.PurchId;

Here is my view:

rmcostview.png

PurchId field is taken from PurchTable.

poDateStr is String Computed Column which View method is latestPODate() method. 

poDateDate is Date Computed Column which View method is supposed to be PODate() method.

Basically here is what written is both latestPODate() and PODate(). The only difference is latestPODate returns String and PODate returns  Date.

public static server date PODate()
{
    SysDictTable dt = new SysDictTable(tableNum(VendPurchOrderJour));

    DictView dv = new DictView(tableNum(RMCostView));

    date s = str2Date(strFmt('SELECT TOP 1 %1 FROM %2 WHERE %2.%3 = %4 ORDER BY %5 DESC',
        dt.fieldName(fieldNum(VendPurchOrderJour, PurchOrderDate), DbBackend::Sql),
        dt.name(DbBackend::Sql),
        dt.fieldName(fieldNum(VendPurchOrderJour, PurchId), DbBackend::Sql),
        dv.computedColumnString(tableStr(PurchTable), fieldStr(PurchTable, PurchId), FieldNameGenerationMode::WhereClause),
        dt.fieldName(fieldNum(vendPurchOrderJour, PurchOrderDocNum), DbBackend::Sql)),123);

    return str2Date(strFmt('ISNULL((%1), \'\')', s),123);
}

The problem is, when I want to select the ViewMethod for poDateDate column, the method PODate() wont appear. Copy pasting the method name won't work.
rmcostviewproperty.png

Why is this happening? Why only methods that returns string is available for selection? 

How to fix this?

Thank You.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    HAIRUL HAZRI Profile Picture
    1,214 on at

    I got it. Just using the latestPODate() method is fine. The date will be automatically converted to Date. I thought there will be problem since they are different in data type. But it works.

    Reference here:

    community.dynamics.com/.../computed-view-columns-in-ax-2012

    Best Regards.

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

News and Announcements

Season of Giving Solutions is Here!

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

#2
TAHER Mehdi Profile Picture

TAHER Mehdi 3

#3
Nakul Profile Picture

Nakul 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans