X++ code to find person based on user Id in D365FO
Views (465)
Hi,
In this post we will view the code to find the person name based on provided user Id in D365FO.
Created a runnable class DAXUserPerson(namely) and added below code.
class DAXUserPerson
{
///
/// Runs the class with the specified arguments.
///
/// The specified arguments.
public static void main(Args _args)
{
DirPerson dirPerson;
HcmWorker hcmWorker;
SysUserInfo sysUserInfo;
DirPersonUser personUser;
DirPersonName dirPersonName;
// Find person based on userId in D365FO
select sysUserInfo where sysUserInfo.Id == 'Admin';
select firstonly RecId from hcmWorker
join personUser
where hcmWorker.Person == personUser.PersonParty
&& personUser.User == sysUserInfo.id
join dirPerson
where personUser.PersonParty == dirPerson.RecId
join dirPersonName
where dirPersonName.Person == dirPerson.RecId;
info(strFmt("Name: %1", dirPersonName.FirstName));
}
}
Output:
Regards,
Chaitanya Golla

Like
Report
*This post is locked for comments