Retrieve employee first, last name, middle name X++ / D365FO
There have been many occasion where, we need to split and return employee FirstName, LastName or MiddleName.
This could either be on a form or most times on a report. The below code should help.
DirPersonName dirPersonName;
DirPerson dirPerson;
dirPerson = DirPerson::find(HcmWorker::findByPersonnelNumber(this.PersonnelNumber).Person); // Get the HcmWorker record.
dirPersonName = DirPersonName::find(dirPerson.RecId);
this.FirstName = dirPersonName.FirstName;
this.LastName = dirPersonName.LastName;
Merci