Name
sn_hr_core.hr_CaseNavigation
Description
Centralizes and manages navigation handlers for HR Cases
Script
var hr_CaseNavigation = Class.create();
hr_CaseNavigation.prototype = {
initialize: function(gr) {
this._gr = gr;
},
/*
* Determines if the rules defined in this script include should apply for the input HR Case
* Called by scripted HR Case Navigation Handlers
*
* @returns {boolean} - True if the input record should have its URI handled by this script; false otherwise
*/
hasRules: function() {
if (!this._gr)
return false;
if (this._shouldRedirectToLatestTransfer(this._gr))
return true;
return false;
},
/*
* Returns an URI for the input HR Case record, given one or more rules defined in this script include
* Called by scripted HR Case Navigation Handlers
*
* @param {String} g_uri - Glide URI object (available from the Navigation Handler)
*
* @returns {string} - URI string to be set as the answer for the Navigation Handler
*/
applyRules: function(g_uri) {
var uri = g_uri.toString();
if (this._shouldRedirectToLatestTransfer(this._gr)) {
var grLatestCase = new hr_TransferCase().getLatestTransfer(this._gr);
g_uri.set('sys_id', grLatestCase.sys_id);
uri = g_uri.toString(grLatestCase.getRecordClassName() + '.do');
}
return uri;
},
_shouldRedirectToLatestTransfer: function() {
if (this._gr.transferred_to.nil())
return false;
var user = gs.getUserID();
if (user == this._gr.opened_for || user == this._gr.subject_person)
return true;
return false;
},
type: 'hr_CaseNavigation'
};
Sys ID
8ec5ff393b7710103585802b13efc436