cancel
Showing results for 
Search instead for 
Did you mean: 

How to get the email address of an employee

Former Member
0 Kudos

Hi,

I am working on SAP Cloud for Travel and Expense and I want to get the email address of an employee.

How can i access and get it.

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hi Taha,

If you are looking for the current logged in employee Email address follow the below code

import AP.PC.IdentityManagement.Global;

import AP.FO.BusinessPartner.Global;

var current_emp_uuid = Context.GetCurrentIdentityUUID();

var current_employee_name;

if(!current_emp_uuid.content.IsInitial())

{

    var bupa_uuid = Identity.Retrieve(current_emp_uuid).BusinessPartnerUUID;

   

    if(!bupa_uuid.content.IsInitial())

    {

        var employee = Employee.Retrieve(bupa_uuid);

        if(employee.IsSet())

        {

            if (employee.CurrentDefaultEmployeeWorkplaceAddressInformation.IsSet())

            {

               var employeeWorkPlaceAddressInfo =                     employee.CurrentDefaultEmployeeWorkplaceAddressInformation;

                    if (employeeWorkPlaceAddressInfo.EmployeeWorkplaceAddressWorkplaceAddress.IsSet())

                    {

                          employeeMailID =                                    employeeWorkPlaceAddressInfo.EmployeeWorkplaceAddressWorkplaceAddress.DefaultEMail.URI.content;

                    }

                }

          }

     }

}

********

If it is the the way round, like if you want to find any specific employee email id then following code will be useful

var employee = Employee.Identification.Retrieve(notification.Source);

if (employee.IsSet())

{

    if (employee.ToParent.CurrentDefaultEmployeeWorkplaceAddressInformation.IsSet())

    {

          var employeeWorkPlaceAddressInfo = employee.ToParent.CurrentDefaultEmployeeWorkplaceAddressInformation;

          if (employeeWorkPlaceAddressInfo.EmployeeWorkplaceAddressWorkplaceAddress.IsSet())

          {

                employeeMailID = employeeWorkPlaceAddressInfo.EmployeeWorkplaceAddressWorkplaceAddress.DefaultEMail.URI.content;

          }

      }

}

Please try the above according to your need

Regards

Hanu

Former Member
0 Kudos

Sorry a correction in one of the above statement of the second block.

var employee = Employee.Identification.Retrieve(EmployeeID);

Along with this use the necessary import statements.

Regards

Hanu

Former Member
0 Kudos

Thank you so much Hanumath for your help.

It works now.

Please,have you an idea on how to edit an email content?

Best Regards,

Former Member
0 Kudos

Hi Taha,

Email content, what you mean by this. Please if you don't mind lets not continue this conversation over in the same thread.

If I am not in a position to give some useful answers others might do for you and solve your issue. This is already marked as answered and less chances of looking into it for new request...

Thanks for understanding...

Regards

Hanu

HorstSchaude
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hello Taha,

Did you take a look at blogs like "New E-Mail Functionality" or "How to send HTML E-Mail"?

Bye,

   Horst

Answers (0)