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, ...
Answered

Static method to get employee name on view

(0) ShareShare
ReportReport
Posted on by 2,108

Hi Techies,

I have customized/extended EntAssetWorkOrderView to update a additional fields in Cube(EntAssetAggregateMeasurement).

There are few fields for which we need to write a method to get the value. e.g. ResponsibleWorker, it's a RecId, we need to fetch an Employee name based on this and show on view.

It seems we can only use the static methods in this scenario. We've followed steps from below MS link to get Employee name from ResponsibleWorker. but the value do not show in cube.

https://docs.microsoft.com/en-us/dynamicsax-2012/developer/walkthrough-add-a-computed-column-to-a-view

Seems there is some issue in code we are trying. Below is a code snippet. Can anyone help anything need to be updated here please-

RecId responsibleWorker = str2Int64(SysComputedColumn::returnField(tablestr(EntAssetWorkOrderView),
identifierstr(EntAssetWorkOrderTable),
fieldStr(EntAssetWorkOrderTable, ResponsibleWorker)));

str responsibleWorkerName = HcmWorker::find(EntAssetWorker::find(responsibleWorker).HcmWorker).name();

return responsibleWorkerName;

Any response is appreciated.

Thank you.

I have the same question (0)
  • Sangram Shinde Profile Picture
    2,108 on at
    RE: Static method to get employee name on view

    Agreed Gunjan I think that's the only approach we need to follow. Thank you!

    Thank you Martin.

    From your answers, there is always something new to learn.

    Regards,

    Sangram

  • Verified answer
    Martin Dráb Profile Picture
    235,961 Most Valuable Professional on at
    RE: Static method to get employee name on view

    As many before you, you misunderstood the purpose of computed columns.

    You seem to think that the method will be executed when you query the data, but it's not the case. It will be called just once, when application objects are created in database, and its purpose is generating a piece of T-SQL code that will be injected to a view definition in database. Obviously, your code doesn't return such SQL code.

    Also, you don't need any methods at all to fetch the name. You can simply use joins (with HcmWorker and DirPartyTable).

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,421 on at
    RE: Static method to get employee name on view

    Hi Sangram,

    Do you need to do this using computed columns only? You can  join HcmWorker and DirPerson to the existing view to add the Responsible worker name.

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 789 User Group Leader

#2
André Arnaud de Calavon Profile Picture

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

#3
Martin Dráb Profile Picture

Martin Dráb 497 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans