By adding a new function to the OOB (hr_CaseUtils) script include, we can achieve this requirement.
var hr_CaseUtils = Class.create();
hr_CaseUtils.prototype = {
initialize : function(_case, _gs) {
if (!_case)
return;
this._case = _case;
this._gs = _gs || gs;
// Other object scripts have a reference here as they are used throughout
this.hrProfile = new hr_Profile(this._case.hr_profile, this._gs);
this.hrUtils = new hr_Utils();
this._ignoreFields = {
'opened_for' : '',
'priority' : '',
'short_description' : '',
'description' : ''
};
this._requiresUserOrProfileCreation = {
'request_onboarding':'',
'new_hire_journey':''
};
},
populateCase : function(service, questions, source) {
var hrServiceGr = new GlideRecord(hr.TABLE_SERVICE);
if (hrServiceGr.get(service) && hrServiceGr.getValue('active')) {
var serviceName = hrServiceGr.getValue('name');
var serviceValue = hrServiceGr.getValue('value');
this._logDebug("Creating new HR Case record for service name: " + serviceName);
this._setServiceFields(hrServiceGr);
this._setGeneralFields(serviceValue, questions);
this._setCommonFields(hrServiceGr, questions, source);
this._mapVariableSetFields(questions);
var extPoints = new GlideScriptedExtensionPoint().getExtensions('sn_hr_core.HRPopulateCaseFields');
for(var i = 0; i < extPoints.length; i++) {
if (extPoints[i].handles(hrServiceGr))
extPoints[i].setFields(hrServiceGr, this._case);
}
}
},
/*
* Updates the variable set fields into the Case.
*/
_mapVariableSetFields: function(questions) {
var parameters = this._getParametersFromQuestions(questions);
var notes = parameters['comments_and_work_notes'];
this._logDebug("Parameters mapped from questions: " + JSON.stringify(parameters));
// Map values from the variable set to the HR case fields
if (notes) {
this._case.work_notes = notes;
}
if (parameters['subject_person']) {
this._case.subject_person = parameters['subject_person'];
}
if (parameters['opened_for']) {
this._case.opened_for = parameters['opened_for'];
}
if (parameters['watch_list']) {
this._case.watch_list = parameters['watch_list'];
}
if (parameters['collaborator']) {
this._case.collaborator = parameters['collaborator'];
}
if (parameters['priority']) {
this._case.priority = parameters['priority'];
}
if (parameters['description']) {
this._case.description = parameters['description'];
}
if (parameters['short_description']) {
this._case.short_description = parameters['short_description'];
}
},
/*
* Updates the service and service offering fields into the Case.
*/