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 :

X++ code to find person email based on user Id in D365FO.

Chaitanya Golla Profile Picture Chaitanya Golla 17,225

Hi,

In this post we will view the code to find the person email based on provided user Id in D365FO.

Created a runnable class DAXUserPersonEmail(namely) and added below code.

class DAXUserPersonEmail
{        
    /// 
    /// Runs the class with the specified arguments.
    /// 
    /// The specified arguments.
    public static void main(Args _args)
    {  
        // Find person email based on userId in D365FO
        RefRecId	hcmWorkerRecId;
        Email		personEmail;
        SysUserInfo sysUserInfo;

        select sysUserInfo where sysUserInfo.Id == 'Admin';

        hcmWorkerRecId = HcmWorker::userId2Worker(sysUserInfo.Id);
        
        personEmail = HcmWorker::emailServer(HcmWorker::find(hcmWorkerRecId).Person);
        info(strFmt("Person Email: %1", personEmail));
    }

}

Output:

DAXUserPersonEmailOutput.jpg

Regards,

Chaitanya Golla

Comments

*This post is locked for comments