HR notification emails show empty values in the email body
HR notifications which are in the Human Resources: Core application scope show empty values in the email notification body.
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.
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.
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.