Show Employee Form Responses directly on the HR Case related (HR Task: Collect Employee Info)
One of the HR Task Type in ServiceNow is called “Collect Employee Info” and can be really useful when the HR Agent needs to collect data from the employee:
As this is a separated record than the HR Case / Task it can be quite inconvenient to look for the responses by the Agent once is completed.
The suggestion is to have instead a related list on the HR Case that show all the child HR Task Employee Forms completed by the employee.
Clicking on any of the Employee Forms in the related list the agent can see the employee responses:
- First click on the Assessment Number
- Second click on the View User’s responses (for this demo I am using a simple Employee form asking the employee if they like ice cream):
In order to make it work on your instance as well you need to create a new Relationship [sys_relationship] (see attachments)
- Name: Employee Form
- Applies to table: HR Case [sn_hr_core_case]
- Queries from table: Assessment Instance []
- Query with:
(function refineQuery(current, parent) {
var hRCase = parent;
var assessmentInstance = current;
var hrCaseId = hRCase.sys_id;
var grHRTasks = new GlideRecord("sn_hr_core_task");
grHRTasks.addQuery("parent", hrCaseId).addOrCondition("parent.parent", hrCaseId).addOrCondition("parent.parent.parent", hrCaseId);
grHRTasks.addQuery("hr_task_type", "collect_Information");
grHRTasks.addNotNullQuery("survey_instance");
grHRTasks.query();
if (!grHRTasks.hasNext())
current.addQuery("sys_id", "NULL");
while (grHRTasks.next()){
current.addQuery("sys_id", grHRTasks.survey_instance);
}
})(current, parent);
Now on the HR Case go to Configure Related List and add Employee Form:
https://www.servicenow.com/community/hrsd-articles/show-employee-form-responses-directly-on-the-hr-case-related-hr/ta-p/2313975