Skip to main content

Notifications

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

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