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

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Old record not populateing in display method in D365Fo

(0) ShareShare
ReportReport
Posted on by 570

Hi All,

Environment : D365FO

I use display method in HcmPositionWorkerAssignment  table on HcmPosition form

source and destination table is HcmPositionWorkerAssignment 

New record only populate on the display method, is not show the old record while debugging its showing empty .

My code 

 [SysClientCacheDataMethodAttribute(true)] //This attribute will cache your display method.
    public static display Name Ename(HcmPositionWorkerAssignment _this)
    {
        HcmPositionWorkerAssignment hcmPositionWorkerAssignmen,hcmPositionWorkerAssignmen1;
        HcmWorker  hcmworker;
        utcdatetime minDateTime = DateTimeUtil::minValue() , maxDateTime = DateTimeUtil::maxValue();
        Name name;
     
      
        select firstonly ValidFrom,Position from hcmPositionWorkerAssignmen order by RecId desc
            where hcmPositionWorkerAssignmen.Position ==_this.Position;
     
          
        select firstonly validTimeState(minDateTime, maxDateTime) * from hcmPositionWorkerAssignmen1 order by RecId desc
            where hcmPositionWorkerAssignmen1.ValidTo < hcmPositionWorkerAssignmen.ValidFrom && hcmPositionWorkerAssignmen1.Position == hcmPositionWorkerAssignmen.Position;
      
            select  hcmworker where hcmworker.RecId == hcmPositionWorkerAssignmen1.Worker;
      
        return hcmworker.name();
}
I have the same question (0)
  • Suggested answer
    André Arnaud de Calavon Profile Picture
    297,611 Super User 2025 Season 2 on at
    RE: Old record not populateing in display method in D365Fo

    Hi Tony,

    The first position: There is no current position assignment (no record on the form), so it will also not do anything on the display method.

    The second example: Have you checked the record IDs of both old assignments? Probably you can't rely on the record ID here as it is technically possible to insert older records after a current one. Then the record ID is higher. Why aren't you sorting on the date then which is probably more reliable here?

  • nmaenpaa Profile Picture
    101,160 Moderator on at
    RE: Old record not populateing in display method in D365Fo

    First of all, it's good to narrow down the problem.

    Either the method is not executed always, or it is executed but the data is not what you would expect.

    When you debug it, is it executed in both scenarios that you tested? When you debug it, are there some unexpected values somewhere that lead it to return different data that you would expect?

  • TonyAx Profile Picture
    570 on at
    RE: Old record not populateing in display method in D365Fo

    Thanks for reply, I mean am getting and displaying the record are same table.

    My Display method name id Incumbent Name

     from 4000-1 Position already record in table, but its not showing on form pls check the below image 

    4000_2D00_1.PNG

    8750.Capture.PNG

     from 4000-2 Position  I created new line in the table, its not showing on form pls check the below image Incumbent Name

    4000_2D00_2.PNG

    40002--table.PNG

  • Martin Dráb Profile Picture
    235,966 Most Valuable Professional on at
    RE: Old record not populateing in display method in D365Fo

    Can you provide a bit more details, please?

    And what do you mean by a source and a destination of a display method? Display method operates on a single record only.

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…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Sohaib Cheema Profile Picture

Sohaib Cheema 823 User Group Leader

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 673 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 491 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans