Skip to main content

How to Synchronize Email Address between User and HR Employee


Whenever you change the email address of a HR Employee record you will notice that this change in the email address is not reflected within the user account. For example for the below employee I changed the email address through a correction update in HR.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhqKVDHP43zd7fpPy1DA8INVryBYIrkpvz9krLHUkwfJCBTmy1Cahn2yi5qkTwlLuJHjRb4HrZcFGpVXQS8tTVn43-vrNgy-i9bkPHrdysD9K3BaMBLa5jtJyuwmsTFEYiCc0moa7MWdGes/s400/SyncEmail.gif

On the account of this user to which the HR Employee record is assigned this change is not reflected.

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjSwIx8UrhYB2ruDrYrdKzoHd4LYwM8-MYBTU1oezbu6P-nJRcUL5-_8x4QOeaKNzGzX4u4WHvHY6baBpNwPPL0gnu74QUNOTocxbK6LCc9c_N6NtXbF6og3BFFAVFsC60h2FRakF_r-TJB/s400/SyncEmail2.gif

In other words the email address assigned to the user and to the related employee do not match. This will generate problems with workflow notifications if they are being sent through the Workflow Notification Mailer.

Currently there is no direct update functionality from HR to the FND_USER table. Oracle will only execute an update to the WF_LOCAL_ROLES table from the APPLSYS schema (for future assignments of the employee to a user). Also after running concurrent program Workflow Directory Services User/Role Validation only the WF_LOCAL_ROLES table is updated and not FND_USER.

SELECT
    *
FROM
    APPLSYS.WF_LOCAL_ROLES
WHERE
    ORIG_SYSTEM = 'PER'
    AND PARENT_ORIG_SYSTEM_ID = <person_id_hr>

Enhancement requests are logged to have this feature as it is crucial for correct Workflow behaviour.

Only remedy for now is to schedule a SQL update to keep the email addresses between HR and the user in sync. Find below the procedure needed to keep things in sync and to avoid Workflow notification problems. Incorporate this in your custom package.

PROCEDURE p_update_email (p_success OUT BOOLEAN)
 IS
      CURSOR c_user_email IS
      SELECT fu.email_address user_email
            ,pap.email_address emp_email
            ,pap.person_id     emp_person_id
      FROM  fnd_user fu
           ,per_all_people_f pap
      WHERE fu.employee_id = pap.person_id
      AND   fu.email_address <> pap.email_address;
      r_user_email  c_user_email%ROWTYPE;
   BEGIN
      p_success := FALSE;
      IF c_user_email%ISOPEN
      THEN
         CLOSE c_user_email;
      END IF;
      OPEN c_user_email;
      FETCH c_user_email INTO r_user_email;
      IF r_user_email.user_email <> r_user_email.emp_email THEN
        UPDATE fnd_user SET email_address = r_user_email.emp_email
        WHERE  employee_id = r_user_email.emp_person_id;
        COMMIT;
        p_success := TRUE;
      ELSE
        p_success := FALSE;
      END IF;
      CLOSE c_user_email;
    
    EXCEPTION
      WHEN OTHERS
      THEN
         p_success := FALSE;
END p_update_email;

Also a direct update can be done on table FND_USER for user records where email addresses are not synced. Fire below update against your instance for an immediate synchronization between APPLSYS.FND_USER and HR.PER_ALL_PEOPLE_F.

UPDATE APPLSYS.FND_USER FUSER
SET FUSER.EMAIL_ADDRESS = (
                            SELECT
                                PAP.EMAIL_ADDRESS
                            FROM
                                HR.PER_ALL_PEOPLE_F PAP
                            WHERE
                                FUSER.EMPLOYEE_ID = PAP.PERSON_ID
                           )
WHERE EXISTS
    (
        SELECT
            PAP.EMAIL_ADDRESS
        FROM
           HR.PER_ALL_PEOPLE_F PAP
        WHERE
            FUSER.EMPLOYEE_ID = PAP.PERSON_ID
            AND FUSER.EMAIL_ADDRESS <> PAP.EMAIL_ADDRESS
    );
Whenever you change the email address of a HR Employee record you will notice that this change in the email address is not reflected within the user account. For example for the below employee I changed the email address through a correction update in HR.

Comments

Popular posts from this blog

SQL Query to extract Oracle Purchase Order Information

SELECT   poh.po_header_id,    poh.type_lookup_code PO_TYPE,   poh.authorization_status PO_STATUS,   poh.segment1 PO_NUMBER,   pov.vendor_name SUPPLIER_NAME,   povs.vendor_site_code Location,   hrls.location_code Ship_To,   hrlb.location_code Bill_to,   pol.line_num ,   msib.segment1 Item,   pol.unit_price,   pol.quantity,   pod.amount_billed Amount,   pod.destination_subinventory,   ppf.full_name Buyer_Name,   poh.closed_Code  FROM   PO_HEADERS_ALL poh,   PO_LINES_ALL pol,   mtl_system_items_b msib,   PO_LINE_LOCATIONS_ALL poll,   PO_DISTRIBUTIONS_ALL pod,   po_vendors pov,   po_vendor_sites_All povs,   hr_locations_all hrls,   hr_locations_all hrlb,   per_all_people_f ppf,   po_line_types polt WHERE   1                         =1 AND polt.line_type_id    = pol.line_type_id AND povs.vendor_site_id     = poh.vendor_site_id AND pov.vendor_id           = poh.vendor_id AND pol.item_id             = msib.inventory_item_id AND msib.organization_id  

Query to find Operating Unit, Business Group and Legal Entity Information

SELECT   DISTINCT   hrl . country ,                  hroutl_bg . name              bg ,                  hroutl_bg . organization_id ,                  lep . legal_entity_id ,                  lep . name                    legal_entity ,                  hroutl_ou . name              ou_name ,                  hroutl_ou . organization_id   org_id ,                  hrl . location_id ,                  hrl . location_code ,                  glev . flex_segment_value FROM     apps . xle_entity_profiles   lep ,         apps . xle_registrations   reg ,         apps . hr_locations_all   hrl ,         apps . hz_parties   hzp ,         apps . fnd_territories_vl   ter ,         apps . hr_operating_units   hro ,         apps . hr_all_organization_units_tl   hroutl_bg ,         apps . hr_all_organization_units_tl   hroutl_ou ,         hr_organization_units   gloperatingunitseo ,         apps . gl_legal_entities_bsvs   glev WHERE    lep . transacting_entity_flag   =   'Y'         AND   l

List of iExpenses Tables

List of iExpenses Tables  Table Name Description AP_EXPENSE_REPORT_HEADERS_ALL Expense report header information AP_EXPENSE_REPORT_LINES_ALL Expense report lines information AP_EXP_REPORT_DISTS_ALL Expense report distribution information. It contains the accounts against each expense report line. AP_CREDIT_CARD_TRXNS_ALL Table to store the corporate credit card transactions that are sent by the banks. These lines are saved as expense lines when the user creates the expense lines for credit cards AP_NOTES Table to store the comments entered by approvers and auditors     Setup tables   AP_EXPENSE_REPORTS_ALL This table contains the header level information about the expense templates AP_EXPENSE_REPORT_PARAMS_ALL This table contains the detail level information about the expense templates AP_POL_CAT_OPTIONS_ALL Table to store the policy options AP_POL_CONTEXT Table to store the policy context     AP_POL_LOCATIONS_TL Table