Retrieving Worker Personal & HR Details in D365FO Using X++
Introduction
In HR and payroll modules of Dynamics 365 Finance & Operations, it’s common to retrieve detailed employee information — from personal details like marital status and gender, to financial dimensions and reporting structure.
In this post, I’ll share how I query D365FO tables to get:
-
Personal details (marital status, gender, birth date, etc.)
-
Age calculation
-
CNIC details
-
Financial dimensions (Department, Business Unit)
-
Reporting hierarchy (Who the worker reports to)
Getting Personal Details of a Worker
Fetch details like marital status, gender, birth date, number of dependents, and ethnic origin.
select hcmPersonDetails
where hcmPersonDetails.Person == hcmWorker.Person
join dirPartyTable
where dirPartyTable.RecId == hcmPersonDetails.Person
join hcmPersonPrivateDetails
where hcmPersonPrivateDetails.Person == dirPartyTable.RecId
join hcmEthnicOrigin
where hcmEthnicOrigin.RecId == hcmPersonPrivateDetails.EthnicOrigin;
Calculating Age
date _asOfDate = HcmDateTimeUtil::currentDate();
age = yearDiff(_asOfDate, hcmPersonPrivateDetails.BirthDate);
Fetching CNIC Details
Retrieve the worker’s CNIC number and expiry date.
select firstonly IdentificationNumber, ExpirationDate
from hcmPersonIdentificationNumber
where hcmPersonIdentificationNumber.Person == hcmWorker.Person;
Getting Financial Dimensions
Fetch Default Dimension for Worker
Get Department Dimension
To get the Business Unit dimension, simply replace 'Department' with 'BusinessUnit'.
Finding Reporting Position
Identify the position (and person) to whom the worker reports.
Comments
Post a Comment