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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Get the latest datetim...
Finance forum

Get the latest datetime value for a computed field in data entity

(0) ShareShare
ReportReport
Posted on by 302

Hello All,

I have created a new data entity and I have 6 datasources in the entity with their respective. I have added a new computed field in which I have to assign the latest modifieddateTime among the 6 datasources available.

Please guide me on this. Please see the below screenshot for your reference,

1425.Capture.JPG

In the above screenshot, if the email is modified recently, I want to return the LogisticsElectronicAddress_Email modified field to my computed field.

Thanks.

I have the same question (0)
  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Hi Wekey,

    There is no "Max" function in SQL, however, it could be implemented using "case when", like:

    case
    when Col1 => Col2 then Col1
    when Col2 > Col1 then Col2
    end


    Case in AX could be implemented using SysCOmputedColumn::switch() method. Use cross references to find examples of switch usage in standard AX.

  • Community Member Profile Picture
    on at

    Im also facing the issue if you fiund the solution let me know

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    Hi AX@beginner,

    actually the original question has been answered by ievgen, so you can find the verified solution right above your own message.

  • Suggested answer
    Martin Dráb Profile Picture
    240,281 Most Valuable Professional on at

    You can use MAX() function for this purpose:

    SELECT MAX(v) FROM (values (T1.ModifiedDateTime), (T2.ModfiedDateTime)) AS value(v)

  • Community Member Profile Picture
    on at

    Thank you Martin, it makes sense in SQL. What would that look like in X++?

    Having some difficulty trying to get the SQL as X++. 

    Trying to us SysComputedColumn::max() function. 

  • Martin Dráb Profile Picture
    240,281 Most Valuable Professional on at

    A computed column method is a method generating a piece of SQL code, therefore is SQL is indeed what you need.

    SysComputedColumn class is there just to help you to generate SQL code. Regarding SysComputedColumn::max(), this is what it does:

    return 'MAX('   _expression   ')';

    Therefore if you want to generate string 'MAX(v)', simply pass 'v' to max():

    SysComputedColumn::max('v');

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans