43 views

HR notification emails show empty values in the email body



Overview


HR notifications which are in the Human Resources: Core application scope show empty values in the email notification body. 

 

Cause


Outbound notifications run as system and system does not have required roles to access HR data present in sn_hr_core table or its child tables. When a HR notification is triggered, it runs as system and tries to access the fields specified in the Message HTML or email script. Since it cannot access the fields, it returns NULL values. 

Solution


To resolve this issue, follow the below steps:

  • Change the notification to Global application scope. 
  • Any fields you would like to display in the notification, use an email script and template.print statements in the email scripts. 
  • Make sure the email script is also in Global application scope. 
  • Add the below line as the first line inside the function. 
    • var origUser = gs.getSession().impersonate('<sys_id of user with sn_hr_core.admin' role>');
  • After all the template.print statements, add the below line as the last line of the function.
    • gs.getSession().impersonate(origUser);

This impersonates the user with sn_hr_core.admin role before trying to access HR data and will revert the impersonation back to system after printing all the data. 

Article Information

Last Updated:2017-11-30 06:47:26
Published:2017-11-30